sql server - Azure SQL Database - Indexing 10+ millions rows -


i have database hosted on azure sql database , below schema single table:

create table [dbo].[article](     [articlehash] [bigint] not null,     [feedhash] [bigint] not null,     [publishedon] [datetime] not null,     [expireson] [datetime] not null,     [datecreated] [datetime] not null,     [url] [nvarchar](max) null,     [title] [nvarchar](max) null,     [summary] [nvarchar](max) null  constraint [pk_dbo.article] primary key clustered  (     [articlehash] asc,     [feedhash] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) 

i have few queries i'm executing slow since table contains on 10 million records:

select *  (select row_number() on (order publishedon desc) page_rn, *       article       (feedhash = -8498408432858355421 , expireson > '2016-01-18 14:18:04.970')      ) paged  page_rn>0 , page_rn<=21  

and 1 more:

select articlehash article (feedhash = -8498408432858355421         , articlehash in (-1776401574438488264,996871668263687248,-5186412434178204433,6410875610077852481,-5428137965544411137,-5326808411357670185,2738089298373692963,9180394103094543689,8120572317154347382,-369910952783360989,1071631911959711259,1187953785740614613,6665010324256449533,3720795027036815325,-5458296665864077096,-5832860214011872788,-2941009192514997875,334202794706549486,-5579819992060984166,-696086851747657853,-7466754676679718482,-1461835507954240474,9021713212273098604,-6337379666850984216,5502287921912059432)         , expireson >= '2016-01-18 14:28:25.883') 

what best way index table queries execute below 300 ms? possible on such big table? azure sql database edition s3.

also, lot of delete/insert actions performed on table indexes should not affect performance of these...

first query benefit native pagination offset , fetch:

select *  article feedhash = -8498408432858355421 , expireson > '2016-01-18 14:18:04.970' order publishedon desc offset 0 fetch next 20 rows 

the second query might benefit substituting in list inner join of table:

declare @articlehashlist table (articlehashwanted bigint primary key); insert @articlehashlist (articlehashwanted) values     (-1776401574438488264),     (  996871668263687248),     (-5186412434178204433),     ( 6410875610077852481),     (-5428137965544411137),     (-5326808411357670185),     ( 2738089298373692963),     ( 9180394103094543689),     ( 8120572317154347382),     ( -369910952783360989),     ( 1071631911959711259),     ( 1187953785740614613),     ( 6665010324256449533),     ( 3720795027036815325),     (-5458296665864077096),     (-5832860214011872788),     (-2941009192514997875),     (  334202794706549486),     (-5579819992060984166),     ( -696086851747657853),     (-7466754676679718482),     (-1461835507954240474),     ( 9021713212273098604),     (-6337379666850984216),     ( 5502287921912059432);  select articlehash article inner join @articlehashlist on articlehash = articlehashwanted feedhash = -8498408432858355421 , expireson >= '2016-01-18 14:28:25.883'; 

creating indexes on dates should lot:

create index idx_article_publishedon on article (publishedon); create index idx_article_expireson on article (expireson); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -