Nikolas
Fri 26 August 2005, 11:25 pm GMT +0300
I would like to introduce you to some very simple techniques that can speed up your queries.
1) LIMIT:
Using the limit statement is the first and most critical query statement, because the dbms ( database management system ) will stop searching when it will found the necessery records. It reduces query time specially in tables with lots of records.
examples : SELECT * FROM table WHERE field = 'value' LIMIT 10
UPDATE LOW_PRIORITY table SET field = 'value' WHERE field = 'value' LIMIT 1
2) UPDATE LOW_PRIORITY
When you are making an update in tables that their data are not about to be used immediately, you can use update statements with LOW_PRIORITY. This way the query will be stored in a buffer, and it will be executed when the server is not busy. This type of query is perfect for statistics, session control and rate it types of tables.
example : UPDATE LOW_PRIORITY table SET field = 'value' WHERE field = 'value' LIMIT 1
3) Allways search indexed fields.
When you are making SELECT statements try to insert indexed fields in the WHERE clause. To create an indexed field use this command:
ALTER TABLE `table` ADD INDEX ( `field` )
Well that's all for now, I will write more when I have more time....
1) LIMIT:
Using the limit statement is the first and most critical query statement, because the dbms ( database management system ) will stop searching when it will found the necessery records. It reduces query time specially in tables with lots of records.
examples : SELECT * FROM table WHERE field = 'value' LIMIT 10
UPDATE LOW_PRIORITY table SET field = 'value' WHERE field = 'value' LIMIT 1
2) UPDATE LOW_PRIORITY
When you are making an update in tables that their data are not about to be used immediately, you can use update statements with LOW_PRIORITY. This way the query will be stored in a buffer, and it will be executed when the server is not busy. This type of query is perfect for statistics, session control and rate it types of tables.
example : UPDATE LOW_PRIORITY table SET field = 'value' WHERE field = 'value' LIMIT 1
3) Allways search indexed fields.
When you are making SELECT statements try to insert indexed fields in the WHERE clause. To create an indexed field use this command:
ALTER TABLE `table` ADD INDEX ( `field` )
Well that's all for now, I will write more when I have more time....
