473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Querry optimization to have better performance

I have the folowing two tables.

employee_master(
emp_rid int primary key identity,
emp_no char(20) not null,
emp_name varchar(100)
);

salary_payment(
sp_rid int primary key,
sp_emp_rid int COMMENT 'Maping employee_master.emp_rid',
sp_pay_date date COMMENT 'Payment Date',
sp_amount varchar(100)
);
Assume in index is created on the fields salary_payment(sp_emp_rid).

Here I need to get all the salary payment details for particular employee
having emp_rid 10234.
For this I have two ways of writing querries.

Method 1:
select * from employee_master
join salary_payment on emp_rid = sp_emp_rid
where emp_rid = 10234

Method 2:
select * from employee_master
join salary_payment on (emp_rid = 10234 = and emp_rid = sp_emp_rid)

Question:
Will these methods make the difference in performance, if yes, how?
Sep 25 '08 #1
2 1193
debasisdas
8,127 Expert 4TB
you need to use method 1 .
Sep 25 '08 #2
you need to use method 1 .

As I understand,
In first method all the rows in the first table is taken into joining, so all the records of employee_master table has to be joined with salary_payment. Then it does the filtering out of emp_rid to match 10234.

In the second method only one record from employee_master table will be considered and then the join operation is less expensive.

So the second method will be better. I have no solid idea of it.
Correct me if I am wrong.
Sep 25 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alex Vinokur | last post by:
For instance, we need to measure performance of assignment 'ch1 = ch2' where ch1 and ch2 are of char type. We need to do that for different optimization levels of the same compiler. Here is...
9
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be';...
93
by: roman ziak | last post by:
I just read couple articles on this group and it keeps amazing me how the portability is used as strong argument for language cleanliness. In my opinion, porting the program (so you just take the...
2
by: gurpreet | last post by:
Hi this is gurpreet, I know this is a very simple question but still I want to clear some doubts. What happens when we compile and link a c-program? I hope aquite a lot of responses to my...
22
by: NigelW | last post by:
This is really a question for the development team. Are there plans to improve the optimization of C# to MSIL? I ask this, as inspection with ILDASM of the MSIL code shows that, even with the...
24
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I...
10
by: Markus Grunwald | last post by:
Hello, while implementing a simple algorithm for digital filters (IIR filters), I got very confused about the very bad performance. This is the code, discussion follows: /**...
0
by: getmeidea | last post by:
I have the following tables, 1> employee_master(emp_id int primary key, emp_name varchar(100)); 2> employee_salary_payment(salary_rid int primary key, emp_id int, sal_date date, paid_amt int); ...
1
by: kasthurirangan.balaji | last post by:
Hi, Below is the code. #include <fstream> #include <set> #include <string> #include <iterator> #include <algorithm>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.