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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:51:55+00:00 2026-05-20T08:51:55+00:00

The following is a query that is taking too long; there are a few

  • 0

The following is a query that is taking too long; there are a few bits to it but it is otherwise a very simple query. I wanted to ask, can anyone see which part of it might be causing a performance bottleneck? Thanks a million.

SELECT DISTINCT node.nid AS nid
  , node_data_field_company_logo.field_company_logo_fid
    AS node_data_field_company_logo_field_company_logo_fid
  , node_data_field_company_logo.field_company_logo_list
    AS node_data_field_company_logo_field_company_logo_list
  , node_data_field_company_logo.field_company_logo_data
    AS node_data_field_company_logo_field_company_logo_data
  , node.type AS node_type, node.vid AS node_vid
  , node_data_field_company_logo.field_job_details_title_value
    AS node_data_field_company_logo_field_job_details_title_value
  , RAND() AS _random
FROM node node
  LEFT JOIN term_node term_node
    ON node.vid = term_node.vid
  LEFT JOIN term_data term_data
    ON term_node.tid = term_data.tid
  LEFT JOIN content_type_profile_job_post node_data_field_company_logo
    ON node.vid = node_data_field_company_logo.vid
WHERE (node.type in ('profile_job_post'))
  AND (node.status <> 0)
  AND ((term_data.name) = (''))
ORDER BY _random ASC
  • 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-05-20T08:51:56+00:00Added an answer on May 20, 2026 at 8:51 am

    First, let’s get rid of all those useless aliases. And pay attention to the comments that asked for table structures, indexes, and EXPLAIN output.

    SELECT DISTINCT node.nid AS nid
      , node_data_field_company_logo.field_company_logo_fid
      , node_data_field_company_logo.field_company_logo_list
      , node_data_field_company_logo.field_company_logo_data
      , node.type, node.vid
      , node_data_field_company_logo.field_job_details_title_value
      , RAND() AS _random
    FROM node 
      LEFT JOIN term_node 
        ON node.vid = term_node.vid
      LEFT JOIN term_data 
        ON term_node.tid = term_data.tid
      LEFT JOIN content_type_profile_job_post 
        ON node.vid = node_data_field_company_logo.vid
    WHERE (node.type in ('profile_job_post'))
      AND (node.status <> 0)
      AND ((term_data.name) = (''))
    ORDER BY _random ASC
    

    Simple things: you’ll usually benefit from an index on any column used in a JOIN clause or a WHERE clause.

    node.status
    node.type
    node.vid
    node_data_field_company_logo.vid
    term_data.name
    term_data.tid
    term_node.vid
    

    But it depends on the number of distinct values in each of those columns. For example, if node.status can have only two values, 0 and 1, then an index probably won’t help with it. (That’s one reason posting your table structures is important.)

    Simple things revisited: you’re going to pay a heavy price for random order.

    Slightly more complex things: you might benefit from creating a view on the node table. The view should select only the columns and rows you actually need here. Then JOIN on that view instead of using the node table directly.

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

Sidebar

Related Questions

I've come across a query that is taking too long. The query has 50+
I have following query which has select query that returns data in 5sec. But
I've got the following query that returns 2 records (in DataSet's query builder) SELECT
I have the following query that runs in my Oracle database and I want
I have the following query that retrieve the number of users per country; SELECT
I have the following query that performs a AND on-demand: var products = //
I have the following query that I ran on my database to remove some
I have the following query that works well. SELECT DISTINCT city,region1,region2 from static_geo_world where
I've got the following MySQL query that I would like to translate so it
Our environment: Drupal+MySQL Examining the query log indicates that the following query, originating 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.