I know (from the answers of this question) that Sqlite by default doesn't enable compression. Is it possible to enable it, or would this require another tool? Here is the situation:
I need to add millions of rows in a Sqlite database. The table contains a description
column (~500 char on average), and on average, each description
is shared by, say, 40 rows, like this:
id name othercolumn description
1 azefds ... This description will be the same for probably 40 rows
2 tsdyug ... This description will be the same for probably 40 rows
...
40 wxcqds ... This description will be the same for probably 40 rows
41 azeyui ... This one is unique
42 uiuotr ... This one will be shared by 60 rows
43 poipud ... This one will be shared by 60 rows
...
101 iuotyp ... This one will be shared by 60 rows
102 blaxwx ... Same description for the next 10 rows
103 sdhfjk ... Same description for the next 10 rows
...
Question:
- Would you just insert rows like this, and enable a compression algorithm of the DB? Pro: you don't have to deal with 2 tables, it's easier when querying.
or
Would you use 2 tables?
id name othercolumn descriptionid 1 azefds ... 1 2 tsdyug ... 1 ... 40 wxcqds ... 1 41 azeyui ... 2 ... id description 1 This description will be the same for probably 40 rows 2 This one is unique
Con: instead of the simple
select id, name, description from mytable
from solution #1, we have to use a complex way to retrieve this, involving 2 tables, and probably multiple queries? Or maybe is it possible to do it without a complex query, but with a clever query withunion
ormerge
or anything like this?