On 30 Oct 2015, at 1:42pm, aa <woshishaoda07 at 163.com> wrote:

>        CREATE TABLE mac_tb  (mac BIGINT PRIMARY KEY?

SQLite doesn't have a BIGINT type.  It will interpret those as integers.

>        If I insert into mac_tb with mac ordey by num desc or asc , then the 
> speed is fast.
>        If I insert the mac randomly, then the speed will grow slower whit the 
> increasing of data. It become slower if the count of mac_tb
> more than 2,000,000.
>        But if i create another table without index, than the speed is so fast.
>        I don't know why the performance difference is so great.

It's to do with how the index is organised on disk.  SQLite is optimized for 
the most frequent case: inserting new rows in order.  You can't do anything 
about the speed for random order so don't worry about it.

If you know you're going to do 2,000,000 INSERT commands, it can be faster to 
DROP the index, insert all the new rows, then CREATE the index again.

Simon.

Reply via email to