Re: [PHP] need help to build a query



In MySQL, you can do "explain $query" to see what MySQL estimates will
be the workload.

Interpreting that output is more art than science, but with practice,
you can at least avoid SOME querie that will drive your server to its
knees.

I did work on a PostgreSQL search engine once where we did a similar
thing in the program and just bailed out if the search was clearly
going to take far too long. Kind of nifty, really...

On Mon, October 9, 2006 3:50 pm, afan@xxxxxxxx wrote:
while I was trying again I did something wrong (?) and my server is
now
"busy" and looks like it went down?!?

The qestion is how can I check first query before I apply it to be
sure
I'm not goig to read every record in my DB or get into loop?

thanks.

-afan

On 10/9/06, afan@xxxxxxxx <afan@xxxxxxxx> wrote:
but I know there must be much better solution then this one.

You're right: Simply JOIN your queries...

SELECT order_id, order_date, order_status, file_name
FROM orders
JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
ORDER BY orders.order_id DESC
LIMIT 100

HTH,
John W



thanks for any help.

-afan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
.



Relevant Pages

  • Re: [PHP] mysql if empty
    ... Your query returned zero rows, a perfectly normal and common condition. ... echo "No result found"; ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] Query question
    ... Subject: Query question ... this should go to a MySQL list. ... > PHP General Mailing List To unsubscribe, ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] array issues
    ... I think you ment ... are doing, but with only the query to look at, it's hard to tell... ... I have paste a sample record below; ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] db query not working
    ... I saw two people pointing two errors on the SQL insert statement which you would have found yourself had you put the 'or die' at the end of the query, ... $result = mysql_query ("SELECT DISTINCT company FROM view_log WHERE company!= ''"); ... It dumps the table fine, works the explode, outputs the string in the echo command the way I expect, but doesn't place the value in tmphitsmag table. ... PHP General Mailing List ...
    (php.general)
  • Re: help with C algorythm (find unique value in an array) could you please make changes
    ... this would not scale well *at all*. ... num_unique_entries/2 accesses per query or insert. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)