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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:14:46+00:00 2026-05-14T06:14:46+00:00

Suppose you want to get a record from database which returns a large amount

  • 0

Suppose you want to get a record from database which returns a large amount of data and requires multiple joins.

So my question would be, is it better to use a single query to check if data exists and get the result if it exists? Or do a more simple query to check if data exists then id record exists, query once again to get the result knowing that it exists.

Example:

3 tables a, b and ab(junction table)

select * from 
from a, b, ab 
where condition
and condition 
and condition 
and condition etc...

or

select id 
from a, b ab 
where condition

then if exists do the query above.

So I don’t know if there is any reason to do the second. Any ideas how this affects DB performance or does it matter at all?

  • 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-14T06:14:47+00:00Added an answer on May 14, 2026 at 6:14 am

    Usually the slowest part in a query is the filter, then it’s the indexed search, joins, etc. If it’s a lot of data to be transfered – the transfer is also time-consuming. It will be twice slower if you check the existence then extract the data. Just extract the data. If it is there you get it, and if not – you get nothing.

    When extracting from multiple tables, JOIN is faster and more flexible.

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

Sidebar

Related Questions

I am having trouble with something I want to get from a database table.
What's the best way retrieve complex queries from a REST service? Suppose I want
Suppose I've got a simple record definition: -record(data, {primary_key = '_', more_stuff = '_'}).
Suppose I want to get several of a file's properties (owner, size, permissions, times)
Suppose I have a list of sets and I want to get the union
Suppose I want to open a file in an existing Emacs session using su
Suppose I want to implement a reasonably efficient 'keyword recognition algorithm', that is first
Suppose you want to make an async request in JavaScript, but you want to
Suppose I want to create a set of observers based on type. That is
Suppose I want to count the lines of code in a project. If all

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.