On Aug 26, 2008, at 1:13 PM, Dave Toll wrote:

> Hello all
>
>
>
> I'm running some general performance tests on SQLite 3.5.9 (embedded C
> platform), and I noticed that creating an index seems to use a lot  
> more
> memory than I expected.
>
>
>
> An index on an integer column (30495 rows) uses 1,011,560 bytes.
>
> DB file size increases by 311,296 bytes.

Perhaps the extra memory is used by additional cache space.  What is  
your cache size set to?  (The default is 2000 pages.)

Have you read http://www.sqlite.org/malloc.html yet?

>
>
>
>
> An index on a varchar column (average null-terminated text length 18
> bytes, 30495 rows) uses 2,180,040 bytes.
>
> DB file size increases by 856,064 bytes.
>
>
>
> I'm using the static memory allocator (mem3.c), page size 4096, and I
> compiled with SQLITE_32BIT_ROWID. I measured the difference in memory
> reported by sqlite3_memory_used(). Dropping the index does not return
> any of the memory used, and does not reduce the DB file size. Are  
> these
> results normal, or is some optimisation possible?
>

The mem3.c allocator is deprecated and will likely go away in a future  
release.  mem5.c is preferred.  The SQLITE_32BIT_ROWID option has not  
been tested by me since I can remember.  I have no idea if it really  
works in all cases or not.  For all I know it causes a memory leak.

Dropping a table or index from a database causes the freed disk space  
to go onto a freelist to be used on the next INSERT.  The space is not  
returned to the OS and the file size is not reduced.  To reduce the  
database file size run VACUUM or enable auto_vacuum.


D. Richard Hipp
[EMAIL PROTECTED]



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to