The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Trouble using LEFTJOIN when table 2 contains 60,000+ records!
I am having BIG problems with pageload times when executing the following query:
PHP Code:
FYI, the function i have created to display the results is as follows: PHP Code:
Thanks in advance for your assistance |
#2
|
||||
|
||||
What indexes do you have on the tables ?
Can you run in debug mode, and then the explain view, and post the result. |
#3
|
||||
|
||||
Thanks, for dma table, my source is as follows:
Code:
`dmacode` int(10) unsigned NOT NULL auto_increment, `zipcode` int(5) unsigned zerofill NOT NULL default '00000', `rank` tinyint(2) unsigned zerofill NOT NULL default '00', `dmaname_clean` varchar(250) NOT NULL default '', PRIMARY KEY (`dmacode`) Code:
`venueid` int(6) unsigned NOT NULL auto_increment, `venuetitle` varchar(30) NOT NULL default '', `venueaddy` varchar(50) default NULL, `venuecitystate` varchar(50) default NULL, `venuezipcode` int(5) unsigned zerofill NOT NULL default '00000', `venuecountry` varchar(20) default 'USA', `venueurl` varchar(80) default NULL, `venuephone` varchar(12) default NULL, PRIMARY KEY (`venueid`) Code:
SELECT erc_venue.*, dma.* FROM erc_venue LEFT JOIN dma ON dma.zipcode = erc_venue.venuezipcode ORDER BY erc_venue.venuetitle LIMIT 0, 12 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE erc_venue ALL 98 Using temporary; Using filesort 1 SIMPLE dma ALL 45534 Time Before: 0.27991 seconds Time After: 7.76009 seconds Time Taken: 7.48018 seconds |
#4
|
||||
|
||||
bump
|
#5
|
||||
|
||||
Add an index on your zipcode columns (both tables) - this will help a lot.
Also, if you alias your tables - you will no longer have to specify the table prefix all over the place: PHP Code:
|
#6
|
||||
|
||||
Thanks SirAdrian,
that was exactly the problem. I had indexed `dmacode` but needed to also create an index on `zipcode`. The query SCREAMS now. thanks again (going to work on using aliases from now on as well) |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|