On Sun, 25 Apr 2010 21:39:43 +0100, Alberto Simões
<hashas...@gmail.com> wrote:

>Hello
>
> I am running on the fly a query to count the number of 
> words starting with one of the 26 letters.
>
> I am doing the usual SELECT COUNT(term) from dictionary WHERE normword
> LIKE "a%"  (for the 26 letters)
>
>normword is the term normalized without accents and the like

Would your application allow to return all 26 in one query?

SELECT COUNT(term) FROM dictionary 
WHERE normword >= 'a'
  AND normword <= 'zzzzzzzzzz'
GROUP BY substr(normword,1,1);

(untested, but certainly faster than 26 separate queries)

>Is there any way to make this query faster? It is taking about 10
>second for 140K entries.
>
>One idea is to add a column named 'letter' and SELECT COUNT(letter)
>from dictionary WHERE letter = 'a'.
>But are there other solutions?
>
>Thanks
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to