sql - Faster count(*) with pivot tables -


my problem in our application complex select on our ms sql server (2008) database made ​​up of several joins (3 , more) used between tables created using pivot (every pivot table has 10 000 rows).

only select quite fast (select returns few rows total 50 10, 000). finding count of records count(*) or filtering slower (for 10 000 records 2 seconds)

is there way speed queries on total number of queries , on filtering? example caching in sql server or optimalization query?

note: query database made our asmx service. note2: every table, contains pivot has primary key type: uniqueidentifier

base select looks this:

select    table1.[id] [id],    table1.[status] [status],    table2.[id] [id],    table2.[status] [status],   (              -- pivot  ) table1 left join (              -- pivot  ) table2 on table2.xxx = table1.yyy  )   --catch first x records.. 

you should use view each of pivot

from ms documentation

after unique clustered index created on view, view's result set materialized , persisted in physical storage in database, saving overhead of performing costly operation @ execution time.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -