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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHERE field = XXX vs WHERE field != XXX : Performance the same? 1

Status
Not open for further replies.

jpo245

Programmer
Jan 16, 2005
45
US
Hi everyone, is there any performance difference btw the following WHERE criteria.

WHERE abcfield = 'XXXX'

vs

WHERE abcfield <> 'XXXX'

A)There are same number of records that for each of the above criteria
B) abcfield is indexed.

This has been puzzling me. At first i thought that WHERE abcfield <> 'XXXX' would be slower, but thinking abt how mysql uses indexes, it might not necessarily be the case.

Thanks!!!
 
If you issue a query in the form:[tt]
EXPLAIN SELECT * FROM tblname WHERE ...[/tt]
it will show you what indexes it uses.

Also, when you run the actual query using either the "mysql" command-line client or MySQL Query Browser, the length of time it took is shown. You would want to run each query a few times, using "RESET QUERY CACHE" between each run.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top