I have a table with the following structure:
id bigNumber text
1 1200321030011010233 "an item with some text"
2 1200321030011014563 "another item with some more text"
3 3120323434432211133 "more...."
... ...
The table contains approximately 50.000 records.
I want to do the following query but it is slow:
SELECT COUNT(*),
bigNumber
FROM items
GROUP BY substr(bigNumber, 1, X)
...where X varies from 2 and 19.
Would it be quicker to create 19 columns with parts of the number in each column to be able to use an index?