c# - Improving SQLite index -
i have sqlite database c# application i'm running in memory (:memory:). table has 650k rows, isn't much. want fast response-times on following query (syntax fetched linq sql dynamic linq query)
select sum([t0].[value1]) [sum], [t0].[dim1] [primary], [t0].[dim2] [secondary] [budgetline] [t0] [t0].[budgetid] = 4 group [t0].[dim1], [t0].[dim2]
which optimal index query? index other primary key looks following...
create index ix_0 on budgetline (budgetid, dim1, dim2) create index ix_1 on budgetline (budgetid) create index ix_2 on budgetline (dim1, dim2) create index ix_3 on budgetline (budgetid, dim1, dim2,value1)
currently execution times varies, around 1s current average. want query take less 0.5s @ least.
the table has 50 columns.
please assist
update: see 4 indexes above, these i'm getting 0.8s response...
remove indexes
create index ix_3 on budgetline (budgetid, dim1, dim2,value1) create index ix_0 on budgetline (budgetid, dim1, dim2)
and use budgetid index provided bartosz (but not dim1, dim2)
an in memory database going limited systems memory - running on underpowered or overtaxed machine? there reason why you're using :memory: instead of actual disk file? (see stack overflow question here)
also consider reading sqlite documentation performance tuning, sqlite performance windows
also try changing sql query follows:
select sum([value1]) [sum] ,[dim1] [primary], [dim2] [secondary] ( select value1, dim1, dim2 [budgetline] [budgetid] = 4 ) group [dim1], [dim2]
Comments
Post a Comment