Calling UPPER() for each field/value while querying is a pain, if you can
assume the names are all in uppercase 
(forcing this in your program before passing them to SQlite), you could
speed up things a lot. But you need to 
analyze what´s happening inside SQlite to check if indices are used, etc.

SQlite command line app has a command that does this (does not remember if
it´s this:
".explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.\n")

'ANALYZE' SQlite command also performs some kind of prefetching of indexes
and loads results in a internal 
table, can help also to speed up.

Also, try to avoid JOINS like this

'SELECT a.* FROM globalRankingTable a, friendTable b WHERE upper(b.player) =
upper('?') AND upper(b.friend) = 

It´s better to explicit use LEFT JOIN / INNER JOIN always.

-----Original Message-----
[] On Behalf Of Roger Binns
Sent: sábado, 10 de julho de 2010 17:39
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Query critique

Hash: SHA1

On 07/09/2010 01:54 AM, Ian Hardingham wrote:
> And here is my query (written in a script language):

Are you actually getting correct answers from this?

>  upper('?') 

Unless your script language includes a SQL parser, that does not do what you
think it does.  It is seeing if the value matches upper cased question mark.
 It looks like you wanted to supply bound parameters so the question mark
should not be in quotes.

I'd also suggest using a better wrapper or scripting language since you are
providing three bindings but the query is only using one of them.  It should

> - yes I know I'm an idiot with the upper stuff, a refactor is needed on 
> that - I know all of my "name" fields should really be integers.

Or look into indices and collations.

In any event you should always post your exact actual query so we don't have
to figure out issues like the question marks are intentional or
transcription errors.

Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla -

sqlite-users mailing list

sqlite-users mailing list

Reply via email to