Skip to content

Instantly share code, notes, and snippets.

@MKorostoff
Created January 29, 2015 00:21
Show Gist options
  • Save MKorostoff/6026a3b51f360084bb5a to your computer and use it in GitHub Desktop.
Save MKorostoff/6026a3b51f360084bb5a to your computer and use it in GitHub Desktop.
<?php
//Example 1: fetch all node IDs using db_select
$startTime = microtime(true);
$result = db_select('node', 'n')
->fields('n')
->execute()
->fetchAll();
echo "Elapsed time is: ". (microtime(true) - $startTime) ." seconds";
//prints 0.25 seconds
//Example 2: fetch all nodes using EntityFieldQuery
$startTime2 = microtime(true);
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')->execute();
echo "Elapsed time is: ". (microtime(true) - $startTime2) ." seconds";
//prints 0.1 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment