#11442: Postgresql backend casts inet types to text, breaks IP operations and
IPv6
lookups.
---------------------------------------------------+------------------------
Reporter: eide | Owner: nobody
Status: reopened | Milestone:
Component: Database layer (models, ORM) | Version: 1.1
Resolution: | Keywords: ipv6
postgres inet
Stage: Accepted | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Changes (by bobrobertson):
* status: closed => reopened
* version: 1.0 => 1.1
* resolution: duplicate =>
Comment:
The resolution assumes this is just an IPv6 problem, and completely
ignores the enormous performance problem introduced by casting every inet
record in the database to a string. This is understandable for LIKE
queries, but it even uses HOST() on exact match queries.
These two queries return the same results. The first is how Django
currently runs this query, and is roughly 2000x slower than the second.
(Yes, I restarted Postgres between tests and flushed the OS buffers, so it
is a fair comparison.)
The difference is performing n inet->string casts vs. performing 1
string->inet cast.[[BR]]
This also fixes the original IPv6 problem in this ticket.
Takes ~30.0 sec:
{{{
SELECT ip from ips where host(ip) = '10.0.0.1'
}}}
Takes ~0.15 sec:
{{{
SELECT ip from ips where ip = inet '10.0.0.1'
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/11442#comment:5>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.