Update problem on large table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hello,Â
I have a very large table that I'm not too fond of. ÂI'm revising the design now.

Up until now its been insert only, storing tracking codes from incoming webtraffic.

It has 8m rows
It appears to insert fine, but simple updates using psql are hanging.

update ONLY traffic_tracking2010 set src_content_type_id = 90 where id = 90322;

I am also now trying to remove the constraints, this also hangs.

alter table traffic_tracking2010 drop constraint traffic_tracking2010_src_content_type_id_fkey;

thanks in advance for any advice.


ÂÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂTable "public.traffic_tracking2010"
   Column    Â|      Type      |               Modifiers              ÂÂ
---------------------+--------------------------+-------------------------------------------------------------------
Âid         Â| integer         Â| not null default nextval('traffic_tracking2010_id_seq'::regclass)
Âaction_time     | timestamp with time zone | not null
Âuser_id       | integer         Â|Â
Âcontent_type_id   | integer         Â|Â
Âobject_id      | integer         Â|Â
Âaction_type     | smallint         | not null
Âsrc_type      Â| smallint         |Â
Âsrc_content_type_id | integer         Â|Â
Âsrc_object_id    | integer         Â|Â
Âhttp_referrer    | character varying(100)  |Â
Âsearch_term     | character varying(50)  Â|Â
Âremote_addr     | inet           | not null
Indexes:
ÂÂ Â"traffic_tracking2010_pkey" PRIMARY KEY, btree (id)
ÂÂ Â"traffic_tracking2010_content_type_id" btree (content_type_id)
ÂÂ Â"traffic_tracking2010_src_content_type_id" btree (src_content_type_id)
ÂÂ Â"traffic_tracking2010_user_id" btree (user_id)
Foreign-key constraints:
ÂÂ Â"traffic_tracking2010_content_type_id_fkey" FOREIGN KEY (content_type_id) REFERENCES django_content_type(id) DEFERRABLE INITIALLY DEFERRED
ÂÂ Â"traffic_tracking2010_src_content_type_id_fkey" FOREIGN KEY (src_content_type_id) REFERENCES django_content_type(id) DEFERRABLE INITIALLY DEFERRED
ÂÂ Â"traffic_tracking2010_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED


This is generated by Django's ORM. Â

The hang may be do having other clients connected, though I have tried doing the update when I know all tracking inserts are stopped.
But the other client (the webapp) is still connected.

based on this:
http://postgresql.1045698.n5.nabble.com/slow-full-table-update-td2070754.html

ns=> ANALYZE traffic_tracking2010;
ANALYZE
ns=> SELECT relpages, reltuples FROM pg_class WHERE relname = 'traffic_tracking2010';
Ârelpages | Âreltuples Â
----------+-------------
ÂÂ Â99037 | 8.38355e+06

and I did vacuum it

vacuum verbose traffic_tracking2010;
INFO: Âvacuuming "public.traffic_tracking2010"
INFO: Âscanned index "traffic_tracking2010_pkey" to remove 1057 row versions
DETAIL: ÂCPU 0.09s/0.37u sec elapsed 10.70 sec.
INFO: Âscanned index "traffic_tracking2010_user_id" to remove 1057 row versions
DETAIL: ÂCPU 0.12s/0.30u sec elapsed 13.53 sec.
INFO: Âscanned index "traffic_tracking2010_content_type_id" to remove 1057 row versions
DETAIL: ÂCPU 0.11s/0.28u sec elapsed 13.99 sec.
INFO: Âscanned index "traffic_tracking2010_src_content_type_id" to remove 1057 row versions
DETAIL: ÂCPU 0.09s/0.26u sec elapsed 15.57 sec.
INFO: Â"traffic_tracking2010": removed 1057 row versions in 535 pages
DETAIL: ÂCPU 0.01s/0.02u sec elapsed 2.83 sec.
INFO: Âindex "traffic_tracking2010_pkey" now contains 8315147 row versions in 22787 pages
DETAIL: Â1057 index row versions were removed.
0 index pages have been deleted, 0 are currently reusable.
CPU 0.00s/0.00u sec elapsed 0.00 sec.
INFO: Âindex "traffic_tracking2010_user_id" now contains 8315147 row versions in 29006 pages
DETAIL: Â1057 index row versions were removed.
0 index pages have been deleted, 0 are currently reusable.
CPU 0.00s/0.00u sec elapsed 0.00 sec.
INFO: Âindex "traffic_tracking2010_content_type_id" now contains 8315147 row versions in 28980 pages
DETAIL: Â1057 index row versions were removed.
0 index pages have been deleted, 0 are currently reusable.
CPU 0.00s/0.00u sec elapsed 0.00 sec.
INFO: Âindex "traffic_tracking2010_src_content_type_id" now contains 8315147 row versions in 28978 pages
DETAIL: Â1057 index row versions were removed.
0 index pages have been deleted, 0 are currently reusable.
CPU 0.00s/0.00u sec elapsed 0.00 sec.
INFO: Â"traffic_tracking2010": found 336 removable, 8315147 nonremovable row versions in 99035 pages
DETAIL: Â0 dead row versions cannot be removed yet.
There were 0 unused item pointers.
25953 pages contain useful free space.
0 pages are entirely empty.
CPU 0.78s/1.49u sec elapsed 100.43 sec.
INFO: Âvacuuming "pg_toast.pg_toast_165961"
INFO: Âindex "pg_toast_165961_index" now contains 0 row versions in 1 pages
DETAIL: Â0 index row versions were removed.
0 index pages have been deleted, 0 are currently reusable.
CPU 0.00s/0.00u sec elapsed 0.01 sec.
INFO: Â"pg_toast_165961": found 0 removable, 0 nonremovable row versions in 0 pages
DETAIL: Â0 dead row versions cannot be removed yet.
There were 0 unused item pointers.
0 pages contain useful free space.
0 pages are entirely empty.
CPU 0.00s/0.00u sec elapsed 0.06 sec.



[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux