Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 23 Jan 2011, 18:42
jscieza jscieza is offline
 
Join Date: Apr 2007
Query optimization request

Hi,

My programmer gave me the following query to get the latest 10 threads created on my forum to be listed in the sidebar of my forumhome (I'm using vB 3.8.x). Issue here is that the query is being listed as slow query (and a very slow one). Please take a look:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

How I can optimize that query?

Thank you,
Jonathan

Last edited by jscieza; 23 Jan 2011 at 22:49.
Reply With Quote
  #2  
Old 23 Jan 2011, 19:15
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I'm not an SQL expert or anything, but that looks pretty much like the same query that forumdisplay.php does except that, in forumdisplay it only does the deletionlog join if the user can see deletion notices. I think the same info about if the thread has been deleted or not is in the visible field (or maybe the open field).

So, assuming you never want deletion notices showing on your main page, you could try deleting the "LEFT JOIN" line and the "AND deletionlog" line and see how that works.
Reply With Quote
  #3  
Old 26 Jan 2011, 02:37
Amenadiel's Avatar
Amenadiel Amenadiel is offline
 
Join Date: Sep 2006
you can ignore the left join. As long as you check for visible=1 you'll be already dismissing deleted threads.

along with the left join you should then remove the sentence "AND deletionlog.primaryid IS NULL"
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 16:43.

Layout Options | Width: Wide Color: