Sample Header Ad - 728x90

Index for constantly updated rows

0 votes
1 answer
145 views
I have a cron on my server that runs every minute, it looks for all registered people who did not have their last connection updated in the last 10 minutes and changes the value in a column in the same table. However, to update this record informing that there was a connection, every 5 minutes the app triggers a request that makes an update. My index would only consist of his status and the date of his last connection, without a primary key. CREATE TABLE userwork ( user_id SERIAL PRIMARY KEY, name VARCHAR(250), owner_id INTEGER REFERENCES owner(owner_id), lastconnection timestamptz, status CHAR(1) ); CREATE INDEX idx_user_lastconnection ON userwork (status, lastconnection); My question is: Can an index for a line that will be constantly updated cause high stress for the server or is it best to create it to avoid an UPDATE that will not search in indexes, just using FILTERS?
Asked by Tom (438 rep)
Feb 5, 2024, 05:08 PM
Last activity: Jul 31, 2025, 11:05 AM