Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long MySQL Query..

Status
Not open for further replies.

5jgibbs

IS-IT--Management
Mar 8, 2005
151
US
I have this query here. It looks at 2 databases and compares values from each table in order to locate the pages that job would have printed. The new database I have fixes this type of issue, so I wont have to do a complex query like this.. But for now, I need to fix this.

This is the query. Any way to speed it up, it takes 2 min! It was much faster with mysql 6.0 alpha but going back to 5.5 its much slower.

SELECT a.user_name, a.job_name, a.printer_name, a.pages FROM printer_acc a WHERE (a.job_name, a.printer_name, a.user_name) IN (SELECT b.job_name, b.printer_name, b.user_name FROM dup b);
 
Excuse me.. I meant 2 tables... not databases..
 
ALTER TABLE printer_acc
ADD INDEX ( job_name, printer_name, user_name );

ALTER TABLE dup
ADD INDEX ( job_name, printer_name, user_name );

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top