is the query I am running , and it takes over 10 seconds to complete this query...
update users set number_recieved=number_recieved+1 where uid=738889333;
table has about 1.7 million rows.. i have an index on column uid and also on number_received. .. this is also slowing down the inserts that happen.
how to fix this?
i have totally 6 different database of similar size in the same machine..j
The hardware is dual quad core intel xeon5405 , and 32GB RAM, and following settings changed..
max_connections = 2000 # (change requires restart)
shared_buffers = 4000MB # min 128kB or max_connections*16kB
effective_cache_size = 12000MB
CREATE INDEX idx_uid
ON users
USING btree
(uid);
CREATE INDEX number_rx
ON users
USING btree
(number_recieved);
table
CREATE TABLE users
(
id serial NOT NULL,
username text,
first_name text,
last_name text,
email text,
"password" text,
last_login timestamp without time zone,
profilepic text,
ip text,
dob timestamp without time zone,
created timestamp without time zone DEFAULT now(),
rawpassword character varying(128),
rating real DEFAULT 0,
zip text,
hash text,
gender character(1),
groups text,
aim text,
yahoo text,
skype text,
hotmail text,
vanity text,
number_comments integer DEFAULT 0,
number_friends integer DEFAULT 0,
number_posts integer DEFAULT 0,
number_polls integer DEFAULT 0,
city text,
site text,
number_pictures bigint DEFAULT 0,
email_subscribe boolean DEFAULT true,
number_userpics integer DEFAULT 0,
htmlcodes text,
pageviews integer DEFAULT 1,
number_uservideos integer DEFAULT 0,
number_useraudios integer DEFAULT 0,
number_usermessages integer DEFAULT 0,
number_usermessages_sent integer DEFAULT 0,
myrand double precision NOT NULL DEFAULT random(),
number_activities integer DEFAULT 0,
number_pages integer DEFAULT 0,
uid integer NOT NULL,
number_invites integer DEFAULT 0,
number_notifications integer DEFAULT 0,
number_emailnotifications integer DEFAULT 0,
number_pendingnotifications integer DEFAULT 0,
total_number_invites integer DEFAULT 0,
total_number_emailnotifications integer DEFAULT 0,
last_invitation timestamp without time zone,
last_emailnotification timestamp without time zone,
session_key text,
last_profilefbml timestamp without time zone,
"name" text,
number_sent integer DEFAULT 0,
number_recieved integer DEFAULT 0,
score integer DEFAULT 0,
number_votes integer DEFAULT 0,
CONSTRAINT users_pkey PRIMARY KEY (id),
CONSTRAINT unique_uid UNIQUE (uid),
CONSTRAINT uniquemail UNIQUE (email),
CONSTRAINT uniquuser UNIQUE (username)
)
WITH (OIDS=FALSE);
ALTER TABLE users OWNER TO postgres;