> Then using distinct() might do the trick: > > entries = entries.distinct()
I try this too in the past, but it doesn't work, because I want to filter out duplicate data in column note. In the other columns might be different values, so in query result isn't 2 or more absolutely identical rows. Am I right, that distinct filter out only identical rows in result? > Or, if you stick with using raw SQL, it's likely better to do > > SELECT DISTINCT note > FROM journals_journal > WHERE length(note) > 0 and note like 'whatever%' > ORDER BY note > > as this tells the DB exactly what your intentions are, and it can > optimize accordingly. Thank you, my SQL knowledge isn't very strong. I compare your and my (GROUP BY) version with EXPLAIN ANALYZE statement in DB, and your variant is faster. I rewrite my code. Thank you again. Regards Michal --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---