From mcp2004 at mail.ru Wed Jun 15 02:25:21 2016 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 15 Jun 2016 10:25:21 +0300 Subject: [dba-SQLServer] =?utf-8?q?Paging_through_1=2E5_million_records_in?= =?utf-8?q?_chunks_of_=7E25=2C000_records=2E=2E=2E?= Message-ID: <1465975521.971271613@f335.i.mail.ru> Hi All -- I have to implement paging in an MS SQL database's one table through its ~1.5 million records in chunks of ~25,000 records in four views/sort orders both ASC and DESC iow total 8 views. This is a desktop application. Using Cast(ROW_NUMBER() over (ORDER BY [{{SortFieldName}}] ASC) as int) RowNumber and then applying WHERE clause to the dynamic RowNumber field is prohibitively time consuming. ? What approach would you propose based on your own experience? Thank you. -- ???????????? ?????? From David at sierranevada.com Wed Jun 15 09:37:14 2016 From: David at sierranevada.com (David Lewis) Date: Wed, 15 Jun 2016 14:37:14 +0000 Subject: [dba-SQLServer] dba-SQLServer Digest, Vol 149, Issue 1 In-Reply-To: References: Message-ID: <82b51a7c04c34137be6b4265a5107cde@cic-ex13mb-03.sierranevada.corp> I would bring the 1.5 million rows (or better, an appropriately sized subset) to the local computer and do the paging there, rather than ask sql server to handle it. ------------------------------ Message: 5 Date: Wed, 15 Jun 2016 10:25:21 +0300 From: Salakhetdinov Shamil To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Paging through 1.5 million records in chunks of ~25,000 records... Message-ID: <1465975521.971271613 at f335.i.mail.ru> Content-Type: text/plain; charset=utf-8 Hi All -- I have to implement paging in an MS SQL database's one table through its ~1.5 million records in chunks of ~25,000 records in four views/sort orders both ASC and DESC iow total 8 views. This is a desktop application. Using Cast(ROW_NUMBER() over (ORDER BY [{{SortFieldName}}] ASC) as int) RowNumber and then applying WHERE clause to the dynamic RowNumber field is prohibitively time consuming. ? What approach would you propose based on your own experience? Thank you. -- ???????????? ?????? ________________________________ The contents of this e-mail message and its attachments are covered by the Electronic Communications Privacy Act (18 U.S.C. 2510-2521) and are intended solely for the addressee(s) hereof. If you are not the named recipient, or the employee or agent responsible for delivering the message to the intended recipient, or if this message has been addressed to you in error, you are directed not to read, disclose, reproduce, distribute, disseminate or otherwise use this transmission. If you have received this communication in error, please notify us immediately by return e-mail or by telephone, 530-893-3520, and delete and/or destroy all copies of the message immediately. From stuart at lexacorp.com.pg Wed Jun 15 17:18:35 2016 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Thu, 16 Jun 2016 08:18:35 +1000 Subject: [dba-SQLServer] Paging through 1.5 million records in chunks of ~25, 000 records... In-Reply-To: <1465975521.971271613@f335.i.mail.ru> References: <1465975521.971271613@f335.i.mail.ru> Message-ID: <5761D43B.8014.542A60A@stuart.lexacorp.com.pg> Can you handle BIGINT in your front end? That CAST on 1.5 million rows will probably be taking up a large part of the time. If that is the problem, how about using SPs so that you pass the WHERE parameters as INTs, but apply them in the SP directly as BIGINTs On 15 Jun 2016 at 10:25, Salakhetdinov Shamil wrote: > Hi All -- > > I have to implement paging in an MS SQL database's one table through > its ~1.5 million records in chunks of ~25,000 records in four > views/sort orders both ASC and DESC iow total 8 views. This is a > desktop application. > > Using > > Cast(ROW_NUMBER() over (ORDER BY [{{SortFieldName}}] ASC) as int) > RowNumber > > and then applying WHERE clause to the dynamic RowNumber field is > prohibitively time consuming. ? What approach would you propose based > on your own experience? > > Thank you. > > -- > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From mcp2004 at mail.ru Thu Jun 16 04:18:06 2016 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 16 Jun 2016 12:18:06 +0300 Subject: [dba-SQLServer] =?utf-8?q?Paging_through_1=2E5_million_records_in?= =?utf-8?q?_chunks_of_=7E25=2C_000_records=2E=2E=2E?= In-Reply-To: <5761D43B.8014.542A60A@stuart.lexacorp.com.pg> References: <1465975521.971271613@f335.i.mail.ru> <5761D43B.8014.542A60A@stuart.lexacorp.com.pg> Message-ID: <1466068686.419701381@f191.i.mail.ru> Stuart -- Yes, that could have been CAST function - I missed it - it was a lot of issues involved here during recent days and T-SQL development wasn't the main my concern. CAST is not needed, I have removed it and my query seems to be working reasonably well now. Thank you. -- Shamil >Thursday, June 16, 2016 1:18 AM +03:00 from "Stuart McLachlan" : > >Can you handle BIGINT in your front end? That CAST on 1.5 million rows will probably be >taking up a large part of the time. If that is the problem, how about using SPs so that you >pass the WHERE parameters as INTs, but apply them in the SP directly as BIGINTs > > > >On 15 Jun 2016 at 10:25, Salakhetdinov Shamil wrote: > >> Hi All -- >> >> I have to implement paging in an MS SQL database's one table through >> its ~1.5 million records in chunks of ~25,000 records in four >> views/sort orders both ASC and DESC iow total 8 views. This is a >> desktop application. >> >> Using >> >> Cast(ROW_NUMBER() over (ORDER BY [{{SortFieldName}}] ASC) as int) >> RowNumber >> >> and then applying WHERE clause to the dynamic RowNumber field is >> prohibitively time consuming. ? What approach would you propose based >> on your own experience? >> >> Thank you. >> >> -- >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com >