optimizing a table's performance using temporary table in sql server 2008 r2 -


good day, i'm quite newbie in optimizing database queries...actually it's first time... i've done research , found out using temporary tables me improve queries performance.. aside other solutions using index though lot of blogs haven't yet find detailed tutorial it... hoping if kindly help. given sample table...

table schemas::

    studentinfo:     studentid      lastname     firstname     yearcode     sectioncode      teacherinfo:     sectioncode     teacherid     teachername       gradeinfo:     studentid     averagegrade      cashierrecord:     studentid     enrolleddate     modeofpayment     amountdue 

query have tried...

 select          s.studentid,         s.firstname,         s.lastname,         t.teacher,         g.averagegrade,         c.enrolleddate     studentinfo s     left join teacherinfo t on s.studentid= t.studentid     left join gradeinfo g on s.studentid= g.studentid     left join graderecords c on s.studentid= c.studentid 

if given query retrieve huge amount of data (ex. 100,000 records) query surely run low in performance... may kindly explain how utilize temporary tables store data multiple tables retrieval easier...

to create table select result in sql server use select into.

select      s.studentid,     s.firstname,     s.lastname,     t.teacher,     g.averagegrade,     c.enrolleddate temptable studentinfo s left join teacherinfo t on s.studentid= t.studentid left join gradeinfo g on s.studentid= g.studentid left join graderecords c on s.studentid= c.studentid 

then use temptable , drop using

drop table temptable 

with have collected data 1 table. temptable not yet real temporary table. here find more on (is necessary use # creating temp tables in sql server?). comes down write #temptable.

but build table still have processing time of select.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -