On Mon, 5 Aug 2013 14:26:00 -0700 (PDT)
Sean Whalen <whalens...@gmail.com> wrote:

> I have a Django/PostgreSQL application to analyze data from tweets. The 
> dataset increases by thousands of records with each request. I am using
> the database primarily as a relational cache, so I had planned to delete
> all records every 24 hours to permit new requests, without needlessly 
> increasing the size of the database.
> 
> However, because the Django ORM uses the
> SERIAL<http://www.postgresql.org/docs/current/interactive/datatype-numeric.html#DATATYPE-SERIAL>data
> type to store the IDs in the DB; the IDs get larger, even when all
> existing records have been deleted. Eventually, I will run out of key
> space. What can I do to make Django produce smaller ID values?
> 

Rather than deleting records could you truncate the table instead? Then
you can reset the sequence with this...

TRUNCATE mytable RESTART IDENTITY

http://www.postgresql.org/docs/9.1/interactive/sql-truncate.html

-- 
Drew Ferguson

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to