sql one : select * from table_name where id = **;
sql two : select count() from table_name where id = **;


I test the two sql statement. It almost the same speed.


At 2016-03-10 16:29:16, "Hick Gunter" <hick at scigames.at> wrote:
>Assuming the "id" is the primary key of your table "table_name", your 
>statement will list the id of all the records present (full scan, reading 
>every entry of the implicit primary key index).
>
>To find out if a specific record exists, use "select count() from table_name 
>where id = <key value>" to return a single row with the number of records 
>found. This may be faster only if id has a primary key or unique constraint or 
>is the first field of a declared index.
>
>-----Urspr?ngliche Nachricht-----
>Von: sqlite-users-bounces at mailinglists.sqlite.org 
>[mailto:sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von Jim 
>Wang
>Gesendet: Donnerstag, 10. M?rz 2016 09:01
>An: sqlite-users at mailinglists.sqlite.org
>Betreff: [sqlite] jude a record is exist or not
>
>hi,all
>    As usual, we judge a record is exist or not in a data base is :select id 
> from table_name.
>    Except the above method, Is there any method which could judge a record is 
> exist or not much faster than the above method.
>
>    I am looking forward to hearing from you.
>    Jim Wang.
>_______________________________________________
>sqlite-users mailing list
>sqlite-users at mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
>___________________________________________
> Gunter Hick
>Software Engineer
>Scientific Games International GmbH
>FN 157284 a, HG Wien
>Klitschgasse 2-4, A-1130 Vienna, Austria
>Tel: +43 1 80100 0
>E-Mail: hick at scigames.at
>
>This communication (including any attachments) is intended for the use of the 
>intended recipient(s) only and may contain information that is confidential, 
>privileged or legally protected. Any unauthorized use or dissemination of this 
>communication is strictly prohibited. If you have received this communication 
>in error, please immediately notify the sender by return e-mail message and 
>delete all copies of the original communication. Thank you for your 
>cooperation.
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users at mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to