Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5969983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:18:32+00:00 2026-05-22T20:18:32+00:00

Well i have the following table(info from pgAdmin): CREATE TABLE comments_lemms ( comment_id integer,

  • 0

Well i have the following table(info from pgAdmin):

    CREATE TABLE comments_lemms
(
  comment_id integer,
  freq integer,
  lemm_id integer,
  bm25 real
)
WITH (
  OIDS=FALSE
);
ALTER TABLE comments_lemms OWNER TO postgres;

-- Index: comments_lemms_comment_id_idx

-- DROP INDEX comments_lemms_comment_id_idx;

CREATE INDEX comments_lemms_comment_id_idx
  ON comments_lemms
  USING btree
  (comment_id);

-- Index: comments_lemms_lemm_id_idx

-- DROP INDEX comments_lemms_lemm_id_idx;

CREATE INDEX comments_lemms_lemm_id_idx
  ON comments_lemms
  USING btree
  (lemm_id);

And one more table:

CREATE TABLE comments
(
  id serial NOT NULL,
  nid integer,
  userid integer,
  timest timestamp without time zone,
  lemm_length integer,
  CONSTRAINT comments_pkey PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE comments OWNER TO postgres;

-- Index: comments_id_idx

-- DROP INDEX comments_id_idx;

CREATE INDEX comments_id_idx
  ON comments
  USING btree
  (id);

-- Index: comments_nid_idx

-- DROP INDEX comments_nid_idx;

CREATE INDEX comments_nid_idx
  ON comments
  USING btree
  (nid);

in comments_lemms there are 8 million entries, in comments – 270 thousands.
Im performing the following sql query:

update comments_lemms set bm25=(select lemm_length from comments where id=comment_id limit 1)

And it takes more than 20 minutes of running and i stop it because pgAdmin looks like its about to crash.
Is there any way to modify this query or indexes or whatever in my database to speed up things a bit? I have to run some similar queries in future and it’s quite painful to wait more than 30 minutes for each one.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:18:33+00:00Added an answer on May 22, 2026 at 8:18 pm

    in comments_lemms there are 8 million entries, in comments – 270 thousands. Im performing the following sql query:

    update comments_lemms set bm25=(select lemm_length from comments where id=comment_id limit 1)
    

    In other words, you’re making it go through 8M entries, and for each row you’re doing a nested loop with an index loopup. PG won’t rewrite/optimize it because of the limit 1 instruction.

    Try this instead:

    update comments_lemms set bm25 = comments.lemm_length
    from comments
    where comments.id = comments_lemms.comment_id;
    

    It should do two seq scans and hash or merge join them together, then proceed with the update in one go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have the following table: CREATE TABLE [dbo].[CampaignCustomer]( [ID] [int] IDENTITY(1,1) NOT NULL, [CampaignID]
We have the following table: CREATE TABLE [dbo].[CampaignCustomer]( [ID] [int] IDENTITY(1,1) NOT NULL, [CampaignID]
Well I am using the following code to redirect users who don't have my
well i have this messages table with sample values like these: msg_id recipient_id read
Okay... So, I came across the following problem: I have one table that works
I have the following table: Table Account{ [...] email varchar(100), [...] } and a
If you have the following: $var = 3; // we'll say it's set to
Well I have a videos website and a few of its tables are: tags
Well I have this MySQL stored procedure that I wrote and if I run
I have several input and option elements on my page, each (well almost) have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.