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 8310305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:24:49+00:00 2026-06-08T19:24:49+00:00

I need to optimize the following query (table group_attributes ) got columns group_id ,

  • 0

I need to optimize the following query (table group_attributes) got columns group_id, attribute_id and int_value.

select  group_id 
from    group_attributes 
where   attribute_id= 1049 
        and int_value in (1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255,
              1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 
              1265, 1266, 1267, 1268, 1269, 1270, 1271)

that group_attributes is a huge table and the query takes forever.

I am not so much of expert in SQL so I wonder which query would work faster? It seems that in general these IN queries are damn slow.

Best, Askar

  • 1 1 Answer
  • 0 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-06-08T19:24:51+00:00Added an answer on June 8, 2026 at 7:24 pm

    Solution – I

    I think you can improve the performance by creating following indexes.

    1. Create Clustered Index on group_id
    2. Non-Clustered index on (attribute_id,int_value)

    Solution – II

    You can also insert all int_values into a temp table and then create the non_clustered index on temp table. Also create non clustered index on int_value of main table.

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

Sidebar

Related Questions

I have the following query: SELECT location, step, COUNT(*), AVG(foo), YEAR(start), MONTH(start), DAY(start) FROM
Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
I have written the following query. select distinct(table3.*), (select count(*) from table2 where table2.cus_id
I have an SQL query with the following structure: SELECT *, storedfunc(param, table.field) as
I need your help to optimize the query to avoid using Using filesort.The job
I need to select a top row for each category from a known set
This is not a homework ;) I need to both A) optimize the following
I need your help to optimize the query below. Let us assume we have
The following query isn't efficient and I need to make it run much faster.
The following PL/SQL block works: DECLARE r TABLE1%ROWTYPE; BEGIN SELECT * INTO r FROM

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.