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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:29:31+00:00 2026-05-27T08:29:31+00:00

1) select * from student_tbl A ,result_tbl B where A.student_name = B.student_name and A.student_name

  • 0

1)

select * from student_tbl A ,result_tbl B where
A.student_name = B.student_name and
A.student_name = "xyz" ;

2)

select * from student_tbl A ,result_tbl B where
A.student_name = "xyz" and
A.student_name = B.student_name ;

I know that the result of these queries are the same.
Is there any performance difference? If so, please explain why.

  • 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-27T08:29:32+00:00Added an answer on May 27, 2026 at 8:29 am

    Queries are not executed like programs. They are not procedures which do step 1 and then step 2. Instead, they are declarative statements about what results you want. In most modern RDBMS’s any given query can be executed via a number of different query plans. Generally, different query plans are created and then evaluated for which plan will run fastest. In creating the set of query plans, it will consider things like which conditions should be evaluated first, whether joins should be done before or after evaluating conditions and other things like that to try to figure out which will be fastest (based on its knowledge of the table sizes and guesses about what percentage of a table will be included in a given condition). Many of them also look at previous results to inform future decisions for when their approximations are wrong.

    Most likely, in any modern RDBMS, those two queries would generate the same set of query plans, and hence the same choice would be made, resulting in the same query plan being executed for both queries. Depending on which RDBMS you are using, there are generally tools available to look at the particular query plans which are being selected for a given query, so you can use that to answer the question absolutely for two specific queries on a particular database.

    Now, saying that, I should note that this is not equivalent to saying "Any two queries which will always produce the same answer on the same data will always take the same amount of time." It is possible to write really bad queries, mostly through needless complexity, and there’s no guarantee that the query planner will realize that you’ve overdone it. It will probably catch simple cases. So, for instance:

    SELECT * FROM student_tbl A, result_tbl B WHERE 
    A.student_name = B.student_name AND
    A.student_name = 'xyz' AND
    B.student_name = A.student_name
    

    will also probably produce the same query plan. And this is also likely to:

    SELECT * FROM student_tbl A, result_tbl B WHERE 
    A.student_name = B.student_name AND
    A.student_name = 'xyz' AND
    B.student_name = 'xyz'
    

    But if you do something really complex like

    (SELECT * FROM student_tbl A, result_tbl B WHERE
     A.student_name = B.student_name AND
     A.student_name = 'xyz')
    UNION
    (SELECT * FROM student_tbl A, result_tbl B WHERE
     A.student_name = B.student_name AND
     B.student_name = 'xyz')
    INTERSECT
    (SELECT * FROM student_tbl A, result_tbl B WHERE
     A.student_name = 'xyz')
    

    It may run a more complex query plan. (Even though, that completely unnecessarily complex query will produce the same results as the other two (assuming no NULLs)).

    So, the optimizers are not omniscient, but they do tend to recognize that X AND Y is the same thing as Y AND X and that A=B AND B=C is the same thing as A=C and A=B and adjust accordingly for those cases. They actually do a variety of transformations to try to find the best query, and are generally quite good at finding it. It is possible to override the decisions of the query planner, but that should only be done when you’re certain that there’s a better way to do the query and that data changes aren’t likely to change that.

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

Sidebar

Related Questions

what would be the result of following query? select StudentName from Students where StudentName
The SQL would be something like select GeneralData.id, GeneralData.name, GeneralData.last_name, Student.id from GeneralData Inner
SELECT * From `users` AS `User` LEFT JOIN `selections` AS `Selections` ON (`Selections`.`user_id` =
SELECT * FROM list WHERE list_item LIKE %_1375_% returns results it should not. For
SELECT * FROM tbl_transaction t LEFT JOIN tbl_transaction_hsbc ht ON t.transactionid = ht.transactionid transactionid
select * from FOO.MBR_DETAILS where BAR= 'BAZ' and MBR_No = '123' execution time =
SELECT * FROM menu WHERE item_id = 1 OR item_id = 2 OR item_id
SELECT * FROM myTable WHERE field1 LIKE 'match0' AND myfunc(t1.hardwareConfig) LIKE 'match1' Here is
SELECT * FROM ExternalQuestionKeyword INNER JOIN ExternalKeywords ON ExternalKeywords.ID=ExternalQuestionKeyword.KeywordID WHERE QuestionID = 17
SELECT * FROM tbl_group_join tgj LEFT JOIN tbl_groups tg ON tg.group_id = tgj.group_id LEFT

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.