Naive pagination
Wed, 05 Nov 08, 10:18:58
filed in
Best practices
I've seen this happen quite a few times and each time it makes me want to bang my head on a table. I saw it again today and it's just so frustrating yet it seems so basic. The scenario is simple:
- you have a database that has some records in it
- you want to display some records on a web page
- you want to paginate through the records
The developer throws a SQL query together like:
select * from log;
Someone throws together a pagination method that looks for the number of results in that record set and then splits it up. You throw together a nice UI to display it. To test it, you set the pagination at 20 records and put 45 records in the database, beautiful and it's all done.
Fast forward a few months... site has come to a crawl. Your log table now has 10 million records in it. To display 20 records on the screen, how many records is the database getting back for you, 20 or 10 million? Again and again, I've seen it where people return 10 million records and then throw all but 20 of them away.
The overhead of producing all those records, sending them over to your application server and then doing whatever needs to be done is of course completely pointless. It's not hard to stop this:
- paginate your SQL correctly, for example Postgresql has LIMIT and OFFSET
- use an ORM that evaluates lazily ensuring that it only queries once you've told it you want 20, for example in Django
- ZSQL Methods in Zope (I don't think many people use them anymore) have a limit of 1000 records to prevent this, if you are upping that number you know something is wrong.
- ZCatalog in Plone is generally ok since it's quite lazy, but there is an overhead. There's an options called
limit and sort_limit ("An optimization hint to tell the catalog how many results you are really interested in"), your mileage may vary there.
And finally if you have a data source that you can't paginate, you have to ask yourself if you can apply the pagination style interface to it. One example was I was asked to create a browse interface to an old LDAP installation. This version of openLDAP did not have an offset meaning that there was no easy way to do it. Ugh.
So if you hear someone say "just list all X here" or "can you just add in pagination" think about the scalability down the line.
Citrix woes
Fri, 02 May 08, 15:26:45
filed in
Best practices
Today was a frustrating day as Citrix kept messing me around. I found that if I ran Windows in a VMWare on my Mac, the client there ran much better. The only problem was finding the Windows client. So I've got an .ica file, you need to run. So you end up at the following page, where next?
One easy place? Yeah right, it's not obvious or easy. Answer it's Citrix XenApp (the new name for Presentation Server). As someone who doesn't know what all the product names mean, there's no way for me to know what the hell to do next.
UK Government IT projects
Sat, 05 Jan 08, 09:03:15
filed in
Best practices
The cost to the taxpayer of abandoned Whitehall computer projects since 2000 has reached almost £2bn
Guardian
Nothing new in here, but this project:
It was being used to report around 30,000 crimes a year but began to falter when defence technology company, Qinetiq, was brought in to build a replacement in 2005. Costs began to spiral and the new system was deemed to be unfit for purpose, resulting in suspension of the service last March and final closure in December. The deal is now subject to a legal dispute, with Qinetiq claiming that it has completed the work it was contracted to do.
Reminds me of this project:
This is in sharp contrast to conventional contracts which attempt to pass on risk – or rather, as Mathew Riley, the company’s commercial director for Terminal 5, ‘the financial consequences of risk’ – to contractors. BAA realised that such contracts do not really work because ultimately either the risk would always fall back on itself, or the attempt to pass on risk would result in massive legal claims and counterclaims.
http://www.christianwolmar.co.uk/articles/pubfinance/apr22,05.shtml
Although Heathrow is possibly as close as you can get to hell on earth, they do have something to teach us.
|
About
Andy McKay works at Clearwind Consulting and can emailed at andy@clearwind.ca. If you are web developer, you need to try Arecibo.
Blogs
Months
-
All
-
February, 10
-
January, 10
-
December, 09
-
November, 09
-
October, 09
-
September, 09
-
August, 09
-
July, 09
-
June, 09
-
May, 09
-
April, 09
-
March, 09
-
February, 09
-
January, 09
-
December, 08
-
November, 08
-
October, 08
-
September, 08
-
August, 08
-
July, 08
-
June, 08
-
May, 08
-
April, 08
-
March, 08
-
February, 08
-
January, 08
-
December, 07
-
November, 07
-
October, 07
-
September, 07
-
August, 07
-
July, 07
-
June, 07
-
May, 07
-
April, 07
-
March, 07
-
February, 07
-
January, 07
-
December, 06
-
November, 06
-
October, 06
-
September, 06
-
August, 06
-
July, 06
-
June, 06
-
May, 06
Categories
|