Page 1 of 1

Queries and server usage.

Posted: Tue Mar 20, 2007 5:27 pm
by Mightywayne
Hmm, been a long time since I've been here. Anyhoo.

I was wondering, when is a query actually counted as being done? I'll just give my example.

Code: Select all

$example = mysql_query("SELECT example FROM example");

// or does it actually get done when called upon? Such as...

if ($example = $example)
{echo "Blah blah."};
Also, I'm wondering if you think having a query on every page the user goes to is bad. Because I want to have custom layouts for folks, and it'll find what layout they've selected, and select the correct .css file.

Posted: Tue Mar 20, 2007 5:37 pm
by feyd
The query is performed immediately under normal circumstances.

A database query per page is a relatively light load as far as I'm concerned. However their preferences could be stored into a session variable to cache the information so you don't need to query.

Posted: Tue Mar 20, 2007 5:50 pm
by Mightywayne
Cool, thanks.

(normal circumstances DOES mean when the variable sets it to it, right?)

Posted: Tue Mar 20, 2007 6:03 pm
by feyd
"Normal circumstances" means where the query isn't set up to perform in a delayed fashion.