One 'trick' I have seen in the past was to create a second table that contained an entry for new records, also keyed by the same "id"; as each sale is created, an entry is also made in that table, possibly by a trigger. You select the records for statistics using a JOIN (inner), which will only return records that are in both tables. As the records are processed, the record is removed from the second table, and therefore the records will not be part of the JOIN in the future. In some databases this may be faster than using an index; I have not experimented with this in SQLITE, however.
-ken
On 15-Apr-05, at 4:30 AM, msaka msaka wrote:
i dont need working with dates and times.. i only set 1 records on which was done..
which index is better to create for this problem?
must i cut db files? or speed of statistic will be same now and after 1000 000 records?
-----Pôvodná správa----- Od: Gert Rijs [mailto:[EMAIL PROTECTED] Odoslané: 15. apríla 2005 7:13 Komu: sqlite-users@sqlite.org Predmet: Re: [sqlite] optimize table
msaka msaka wrote:
CREATE TABLE sale( id INTEGER NOT NULL UNIQUE PRIMARY KEY, bill_no integer, bill_item_no integer, item_name varchar(20), qty integer, amount DOUBLE, statistic integer )
Why don't you replace "statistic" with a timestamp formatted like yyyymmdd, perhaps add the time as well. If you add an index on it you can efficiently retrieve the rows for certain date periods without needing to update the table.
Gert