Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-22-2006, 05:47 PM
Alex Buell
 
Posts: n/a
Default Optimising queries

Hi!

I wonder if anyone can tell me if there is anything I can do to make
this set of queries a lot more efficient. Right now I have this code
that lists statistics as below:

Guestbook Statistics

Comments: 42 records

2003-06: 6
2003-07: 4
2003-08: 1
2003-09: 4
2003-10: 1
2003-11: 2
2003-12: 1

2003: 19
--------------------

2004-01: 1
2004-02: 1
2004-03: 3
2004-04: 1
2004-05: 1
2004-08: 3
2004-10: 1
2004-11: 1

2004: 12
--------------------

2005-01: 1
2005-03: 1
2005-06: 1
2005-07: 3
2005-08: 2

2005: 8
--------------------

2006-05: 3

2006: 3
--------------------

And the code that produced this is as follows:

"SELECT DISTINCT(SUBSTRING(entry, 1, 4)) AS years FROM guestbook ORDER
BY years ASC"

"SELECT COUNT(entry) AS total FROM guestbook WHERE entry LIKE '". $year
.. "%'";

"SELECT DISTINCT(SUBSTRING(entry, 1, 7)) AS months FROM guestbook WHERE
entry LIKE '" . $year . "%' ORDER BY months ASC"

"SELECT COUNT(entry) AS days FROM guestbook WHERE entry LIKE '".
$months . "%'"

I'd welcome any comments that might make this work a lot better. I
think what I've written is really crap and the network gets a bit
overloaded when I execute these queries.

Thanks for any advice offered.
--
http://www.munted.org.uk

Take a nap, it saves lives.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:07 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.