BillyRayPreachersSon
Programmer
Hi,
I want to select some records based upon the first 3 characters of one of their fields.
All of the following commands work perfectly for me, and on my small local dataset (10 or so records out of 40), there's no noticeable difference in speed:
What I want to know is, which method would be better when scaled up to a larger number of records (perhaps 1000)?
My hunch is that INSTR would be faster than LIKE or REGEXP, but not sure about the other string ones.
Any advice?
Thanks!
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign
I want to select some records based upon the first 3 characters of one of their fields.
All of the following commands work perfectly for me, and on my small local dataset (10 or so records out of 40), there's no noticeable difference in speed:
Code:
SELECT * FROM Page WHERE name LIKE 'bus%';
SELECT * FROM Page WHERE name REGEXP '^bus';
SELECT * FROM Page WHERE LEFT(name, 3)='bus';
SELECT * FROM Page WHERE INSTR(name, 'bus')=1;
SELECT * FROM Page WHERE LOCATE('bus', name)=1;
SELECT * FROM Page WHERE SUBSTRING(name, 1, 3)='bus';
What I want to know is, which method would be better when scaled up to a larger number of records (perhaps 1000)?
My hunch is that INSTR would be faster than LIKE or REGEXP, but not sure about the other string ones.
Any advice?
Thanks!
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign