Re: MS-SQL server LIMIT/OFFSET implementation

2006-07-21 Thread Dan Hristodorescu
Yes, you could do that, but it's not what you would want.It will become visible slower when the offset increases because you have to iterate through the previous rows.The nice Python syntax hides this detail but the driver has do it. This is because the cursor is a forward cursor and you have to i

Re: MS-SQL server LIMIT/OFFSET implementation

2006-07-21 Thread DavidA
> > On Thu, 2006-07-20 at 17:34 -0400, Dan Hristodorescu wrote: > > > > > > and for SQL 2000 should look like this: > > > > > > SELECT fields FROM table > > > WHERE primary key IN > > > (SELECT TOP limit primary_key FROM table > > > WHERE primary_key NOT IN > >

Re: MS-SQL server LIMIT/OFFSET implementation

2006-07-20 Thread Dan Hristodorescu
Thanks Malcolm,I wasn't aware of it.I suspect Adrian intends to refactor the code along the same lines I would have to.Basically a more fine grain construction of the SQL string, providing internal access the different parts of the SQL: the field list, the FROM table list, the WHERE clause and the

Re: MS-SQL server LIMIT/OFFSET implementation

2006-07-20 Thread Malcolm Tredinnick
On Thu, 2006-07-20 at 17:34 -0400, Dan Hristodorescu wrote: > Hi Ivan, > > I looked in the code and it seems that QuerySet class needs some > serious refactoring to support MSSQL paging. > For SQL 2005 the SQL string should look like this: > > WITH myTable AS > (SELECT fields, ROW_NUMBER() OVER

Re: MS-SQL server LIMIT/OFFSET implementation

2006-07-20 Thread Dan Hristodorescu
Hi Ivan,I looked in the code and it seems that QuerySet class needs some serious refactoring to support MSSQL paging.For SQL 2005 the SQL string should look like this:WITH myTable AS(SELECT fields, ROW_NUMBER() OVER (order by orderclause) AS RowNumber FROM table) SELECT * FROM myTable WHERE RowNumb

Re: MS-SQL server LIMIT/OFFSET implementation

2006-07-20 Thread Ivan Sagalaev
DanH wrote: > > Is someone working on MS-SQL support? > I would like to help if possible with the implementation and testing. Yes, testing is the main thing that holds it. The patch was developed sporadically and as far as I remember all the theoretical problems were known how to solve. It's j

MS-SQL server LIMIT/OFFSET implementation

2006-07-19 Thread DanH
Hi, I would like to use Django with MS-SQL server and the svn version doesn't work yet. I submitted a patch to make it work: http://code.djangoproject.com/ticket/2358 It's not ideal, just a quick fix until I get a better understanding of Django internals. What is missing right now is LIMIT/OFFSE