sql - PostgreSQL CASE statement requires indexes? -
sql - PostgreSQL CASE statement requires indexes? -
i after advice please.
i have written case statement populate new field. database table of on 300 1000000 records took approx 12 hours.
update line set code = (case when (group ='{building}' , term = '{outline}') 1 when (group ='{building}' , term = '{division}') 2 when (group ='{building}' , term = '{partial}') 3 else 99 end) code null; what increment performance?
should add together index code column before running case statement can find records have null code value quicker.
or should create indexes on columns 'group' , 'term' help speed up.
with table big take while create indexes has balance time taken create them , resulting performance gain.
thanks advice
edit additional info
am using postgresql 9.2 64bit on windows 2008 server have used postgresql tuning wiki , have optimised postgresql.conf file have done vacuume , analyze on table
an index on code not going help case statement, help where. there "give-and-take" on this, because index needs updated original data. so, if code values null, index not faster.
an index on group , term help if split separate updates:
update line set code = 1 code null , grouping = '{building}' , term = '{outline}'; actually, index want line(code, group, term) these.
sql postgresql
Comments
Post a Comment