Jump to content

Which method is faster and more effective?


mkosmosports

Recommended Posts

I have a database full of teams and dates when the teams start out. For this particular tournament teams enter at 4 different stages (dates)...

What is quicker?

1. Do four different mysql queries which would return only the teams during selected date intervals?
2. Do one query which would return all teams and then use php to separate out what is to be returned when?

Thanks..
Link to comment
Share on other sites

how about running a test?

[code]
<?php
function timer()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

$t1 = timer();
// do method 1

$t2 = timer();
// do method 2

$t3 = timer();

$total1 = $t2-$t1;
$total2 = $t3-$t2;
echo "Method 1 :  $total1 <br />";
echo "Method 2 :  $total2 <br />";
?>
[/code]

edit: I stoled this code snippet from barand's poll. not that i couldn't have done it myself, but i'm lazy such and all.  just giving credit where credit is due ;D
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.