September 8, 2008 at 10:37 am
hi all ,
i need to know the best practice in writing queries as my web application has 3 million records and it follows 3rd normalization. I find my queries are taking more than 10 seconds to outpu the result.Please calrify my below questions.
1,is there is any order needed to be followed in the where condition.
for example consider the below table.
Employee:
EmpID (pk)
EmpName
City
StateId(fk)
CountryId(fk)
now if i want to retrieve the information about a particular employee (statename,Countryname and not ids) should i need have the where condition in this order?
where empiD=? and employee.stateID=state.stateId and employee.countryID=Country.countryId
2 We have bulk insert and dat file generation so i have written a procedure to do this but while inserting the bulk records and generating the DAT will the tables used in this will be locked or will the rows be locked ? also can others read the data from the row at the same time when this bulk update/insert happens.
3.Can other session view the uncommited data in the bulk insert's session
pls help.
4. how does the o\locking happens when i have a begin and end transaction?
Thanks,
Prem
September 8, 2008 at 11:24 am
1. order in the WHERE clause does not matter.
2. What's the dat? This doesn't make sense in SQL Server.
3. Not sure, might depend on the isolation levels set on the connections.
4. This doesn't make sense. Please reword or explain what you mean. What is o/locking?
September 8, 2008 at 11:25 am
To make it easier for yourself use object aliasses in your queries and the JOIN syntax.
It differentiates join and where clause.
[Code]
Select e.name,
S.name,
C.name
from Employee E
inner join State S
on S.Id = E.StateId
inner join Country C
on C.Id = E.CountryID
where E.empiD=...
[/Code]
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply