Try using the sqlite shell program and the explain feature. You will see that 
each column fetched requires an additional opcode to do the fetching and an 
additional register to hold the result, all of this on top of requiring SQLite 
to decode all of these fields without you ever intending to use the results of 
all this CPU labor.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Jens Alfke
Gesendet: Samstag, 15. Oktober 2016 20:01
An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Betreff: [sqlite] Any performance penalty for SELECTing more columns? (C API)

In a simple SELECT query of a single table, using the C API, is there any 
difference in performance for requesting more or fewer columns of the table in 
the result? Or is the performance penalty only incurred when actually reading 
the column values?

For example, lets say a table has 26 columns, some of which can be large 
strings/blobs. I prepare two statements:
        SELECT a FROM mytable WHERE …
        SELECT a,b,c,d,…,z FROM mytable WHERE … If I run both of those queries, 
but in my loop I only read the value of ‘a’, by calling 
sqlite3_column_text(stmt, 0), is there any difference in speed?

I am guessing that there isn’t a difference. (I could run tests, but I don’t 
want to be dependent on a detail that might change.) If so, this will make it 
easier to create my queries, since I won’t have to fine-tune their column sets 
based on what columns I need in each different use case.

—Jens
_______________________________________________
sqlite-users mailing list
sqlite-users@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: h...@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@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to