Author |
Topic  |
Podge
Support Moderator
    
Ireland
3776 Posts |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 07 October 2009 : 17:41:36
|
quote: Originally posted by Podge
Thanks HuwR. I think you missed the point of my question, which was - you can only use the columns in the order that they were selected.
No, I didn't, you can use them in any order, the issue is that with some versions of MDAC ALL MEMO FIELDS must come last in the select statement.
the MS-SQL forum is for microsoft flavoured SQL, the My-SQL forum is for my-sql flavoured SQL since they are not the same, that is why there is a forum for each db type, they all use slightly different SQL
have never come across any issues with forum.asp regardless of how many pages of topics it returns, how many rows/pages are you talking about |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
Posted - 07 October 2009 : 18:11:30
|
That makes it clearer. Thanks.
quote: have never come across any issues with forum.asp regardless of how many pages of topics it returns, how many rows/pages are you talking about
In this particular forum its retuning 4297 rows when you really only need 20 rows and the number of pages (or the total rowcount) to calculate paging. The first few times I load forum.asp nothing shows up. When the query finally returns all the records its cached by sql server so that subsequent requests for it are returned much faster. The problem I have is that I have hundreds of very large forums, resulting in many hundreds of thousands of rows being returned (with 500 concurrent users, lots of them are viewing forum.asp at the same time). MySql has the LIMIT keyword but MSSQL 2000 doesn't. Am I mis-understanding how paging works on forum.asp ? |
Podge.
The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)
My Mods: CAPTCHA Mod | GateKeeper Mod Tutorial: Enable subscriptions on your board
Warning: The post above or below may contain nuts. |
Edited by - Podge on 07 October 2009 18:12:37 |
 |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 07 October 2009 : 19:07:19
|
you would have to implement your owwn paging using a stored procedure (the .Net version does that), see here for an example |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
Posted - 08 October 2009 : 07:05:03
|
This is the problem query (contains mod columns that you may need to remove to test on your forum)
This is what I've come up with (no need for a stored procedure).
[pagesize] is the amount of rows per page you want i.e. 15 topics per page [offset] is zero based and can be calculated by multiplying the pagesize by the page number you want and subtracting 1 from this total for example
15 topics per page and you want page 1 then offset = (0 * 15) = 0 (rows 0-14) 15 topics per page and you want page 2 then offset = (1 * 15) = 15 (rows 15-29) 15 topics per page and you want page 3 then offset = (2 * 15) = 30 (rows 30-44)
The greater the page number you want the less efficient the query is however it should still be better than returning all rows.
I didn't have much time to test it out fully. Any one see any problems with this method ? |
Podge.
The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)
My Mods: CAPTCHA Mod | GateKeeper Mod Tutorial: Enable subscriptions on your board
Warning: The post above or below may contain nuts. |
 |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 08 October 2009 : 10:41:48
|
why not do this
there is no need to select all those values in the second query |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 08 October 2009 : 13:03:11
|
seemed to work ok with the quick test I ran, but don't have any excessively large forums to test it on
actually it allways fetches the same 15 records 
|
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 09 October 2009 : 03:10:28
|
yes, I was changing the offset, but in sql enterprise manager it returns the same 15 records every time, and looking at the logic it should never do anything other than that, normally to do what you are attempting one query is ordered ascending and the other descending, yours both order in the same direction so logically should not work.
the method your are trying to employ normally goes like so.
select top 10 * from table1 where id in (select top 20 id from table1 order by X desc) order by X asc
|
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 09 October 2009 : 09:01:39
|
I'm sure I did that, but I will check , maybe I didn't  |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 09 October 2009 : 09:49:52
|
that was why I suggested a stored proc, the query required is much simpler  |
 |
|
Topic  |
|
|
|