I am using django latest trunk and postgresql 8.2 The domain relation contains 180 million records.
class Domain(models.Model): name = models.CharField("domain name", maxlength=255, unique=True) source = models.ForeignKey(History, verbose_name="Source") CREATE TABLE "DNS_domain" ( "id" serial NOT NULL PRIMARY KEY, "name" varchar(255) NOT NULL UNIQUE, "source_id" integer NOT NULL REFERENCES "Log_history" ("id") DEFERRABLE INITIALLY DEFERRED ); 1/ If I try to catch an integrityerror exception, all subsequent inserts will still fail. Why not use a savepoint and rollback to recover from an integrity error exception. 2/ If you check that an object exists before a save, there is a race condition that may generate an exception if the object is created independently by another process. 3/ Django probably need a simple and fast method to check if an object exists. This would be really useful when doing bulk inserts; I don't care about the existing objects I just want to avoid collision. 4/ Why is my select is 2 times faster than objects.get(name=domain)? What is causing the overhead? d = Domain.objects.get(name=domain) [...] Checked 90000 domains at 1434 domain/s Now if instead I just do: cursor.execute("""SELECT id,name from "DNS_domain" WHERE name='%s' """ % domain) row = cursor.fetchone() Checked 90000 domains at 3659 domain/s Thanks, K. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---