On Feb 2, 2:15 am, Ed Hagen <eha...@gmail.com> wrote:
> £ukasz, Thanks for your comments.
>
> > Could you describe your current solution in more detail?
>
> Well, my use of the term "solution" was perhaps a bit generous. First,
> I educated my users why this problem was hard to solve. Second, I
> picked a single collation that everyone could live with. Third, I used
> the locale module to sort on the application side, which, as you say,
> was slow. But because the data don't change much, I was able to cache
> the result to achieve acceptable performance.
>
> Even if application-side sorting is slow, nevertheless, in many cases
> that will be preferable to users not finding what they are looking for
> because the item doesn't show up where it "should." So it's a tradeoff
> between two aspects of user experience (speed vs. expected sort
> order). In many cases, that tradeoff would favor language-specific
> collation.

The problem is that application side sorting does not scale. So, if
you are depending on application side sorting, there will likely come
a day when you have so much data that it is simply impossible to do
the sorting Python-side. Databases are a lot faster at sorting,
especially with indexes.

Now, my proposed solution would be to have some way of doing:
SELECT name, ...
FROM authors
ORDER BY name collate 'fi';

That some way might be something like
.order_by('name', collate='fi')
or maybe
.collate('fi').order_by('name')
and now collate would be in effect for filters (that is,
name__gte='e'), too.

Making Django's ORM do the above isn't the most trivial thing. And not
all databases support collate clauses.

You can do the above with .extra() even now if your DB happens to
support collations. Default collation for your database might also be
an option for your particular problem. At least in PostgreSQL versions
prior to 9.1 you have one collation for the DB, which you can set only
at CREATE DB time.

Anyways, Django's design decision is to do sorting in the DB. And I
think that is a good decision.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to