0

it's my update -

UPDATE "users" SET "name" = $?, "is_read" = $?, "updated_at" = $? WHERE "users"."id" = ?

and sometimes it takes about 150 seconds(but in normaly - it's fast). Could you please advise me possible reasons? users.id have index

Artoym P
  • 53
  • 1
  • 5

1 Answers1

0

To speed this update, you want an index on users(id):

create index idx_users_id on users(id)

Normally, the id would be declared as a primary key (or at least unique) and already have an index. But if it isn't, this should help.

Note: There are other possibilities, such as other processes having a lock on the table or very complex insert triggers.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786