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

  • Home
  • SEARCH
  • 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 8219383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:08:20+00:00 2026-06-07T13:08:20+00:00

I have a query that selects any information from a db. This information I

  • 0

I have a query that selects any information from a db. This information I will use for defining the article price. The problem is that the query takes 3 seconds to execute. This time must to be multiply for many article.

How can I optimize this query? In the articoli table there are 16 330 rows.

This is the query

SELECT ts_scon, AI_CODICIVA, 
       AI_LIS_EURO1, AI_LIS_EURO2, 
       AI_LIS_EURO3, AI_LIS_EURO4, 
       AI_LIS_EURO5, cl_tipocl
  FROM tabscon, articoli, clienti
 WHERE ts_azienda = 'SRL' 
   AND AI_AZIENDA = 'SRL'
   AND AI_CODIREST = $cod_articolo 
   AND cl_azienda = 'SRL' 
   AND cl_codice = $cod_cliente
   AND ts_codice IN (
        SELECT cl_tabsco 
          FROM clienti 
         WHERE cl_codice = $cod_cliente 
           AND CL_AZIENDA = 'SRL')
   AND ts_grusco IN (
        SELECT ai_grupscon 
          FROM articoli 
         WHERE ai_codirest = $cod_articolo  
           AND AI_AZIENDA = 'SRL')

This is the EXPLAIN result. The results are the same with indices that without indices.

id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra
1|PRIMARY|clienti|const|PRIMARY|PRIMARY|25|const,const|1
1|PRIMARY|tabscon|ref|PRIMARY,azie_grsco_codice|PRIMARY|15|const|505|Using where
1|PRIMARY|articoli|ALL|PRIMARY,barcodeidx,StatoAidx,Statoidx|NULL|NULL|NULL|16333|Using where; Using join buffer
3|DEPENDENT SUBQUERY|articoli|ref|PRIMARY,barcodeidx,StatoAidx,Statoidx StatoAidx|15|const|7311|Using where
2|DEPENDENT|SUBQUERY|clienti|const|PRIMARY

Sorry for the little order but not yet practical.

  • 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-07T13:08:21+00:00Added an answer on June 7, 2026 at 1:08 pm

    Query-wise the best way to do this would be.

    SELECT ts_scon, a.AI_CODICIVA, 
      a.AI_LIS_EURO1, a.AI_LIS_EURO2, 
      a.AI_LIS_EURO3, a.AI_LIS_EURO4, 
      a.AI_LIS_EURO5, c.cl_tipocl
    FROM tabscon t
    JOIN articoli a ON ts_azienda = ai_azienda
    JOIN articoli a2 ON ts_azienda = a2.ai_azienda AND a2.ai_codirest = $cod_articolo AND a2.ai_grusco = ts_grusco
    JOIN clienti c ON ai_azienda = cl_azienda
    JOIN clienti c2 ON ai_azienda = c2.cl_azienda AND c2.cl_codice = $cod_cliente AND c2.cl_tabsco = ts_codice
    WHERE ts_azienda = 'SRL' 
    AND AI_CODIREST = $cod_articolo
    

    That said, I’m not sure exactly what information you’re trying to get here; you may not need to join onto those tables twice, but without understanding the data I can’t be sure.

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

Sidebar

Related Questions

I have a query that basically combines tables of actions and selects from them
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have a query that looks like this SELECT * from myTable WHERE Date
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM
I have a relatively light query that needs information from a local MySQL table
I have a query that selects rows in a ListView without having a limit.
I have a SELECT query that I am expecting millions of results from. I
I have a query that looks like this: var ChangesOthersResult = surveyResponseRepository.Query.Select(r => r.ChangesOthers);
I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
I have a particularly complicated query for a report. It selects several columns 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.