About MEDITECH Reports

 

View John Sharpe's profile on LinkedInI'm your host, John Sharpe, a MEDITECH Consultant living in Spokane, WA. Read more ...

Connect ...

Expand your network by connecting on these social media sites:

Sign up for the MEDITECH Reports Blog; details to attend MEDITECH workshops are sent out 1 week in advance to all MEDITECH Report blog subscribers.

These MEDITECH Workshops are sponsored by Donna Carroll at the MEDITECH Community Bulletin

MEDITECH NPR & RW RESOURCES:

Ascii Table: For NPR Report Writer
Loop Builder: For NPR Macros
Key Codes: For CDS Attributes
List Builder: For NPR Macros
MT Report Names: For NPR Reports
MT Structure Viewer: For Physicals
Strings: Format & Sort

HIT Topics

MEDITECH Reports

Current Articles | RSS Feed RSS Feed

SQL Server Temp Table Best Practices (v0.01) for MEDITECH

 

Gary my DBA says, you're trying to do too much in your query.  With over 20 joins and 200+ fields in my MEDITECH DR query; I knew he was right.  Gary suggested Temp Tables over the Common Table Expression (CTE) I was using.

At 50,000 feet creating and using temp tables goes like this.

Sql Server Temp Table

My newest script utilizing temp tables, can be found at the MEDITECH Open Source - SQL for Data Repository, and may be just what you need to improve performance on a T-SQL script of your own.

MEDITECH DR SQL Repository >> SQL Server Temp Table Script

Sql Server Temp Table Tsql Script resized 600

SQL Server temp tables can be just the solution for queries with many joins on large MEDITECH DR tables. 

sql server dr meditech

UPDATE: after implementing the query using temp tables, the run time improved from 9 hours to a blistering 52 seconds. 

References:

  1. Temp Tables in SQL Server
  2. SQL Server CTEs vs Temp Tables vs Table Variables
  3. SQL Server Temporary Table Usage

Want an alert when the next post is published? Click the phone and Subscribe to the MEDITECH Reports Blog!

Subscribe to the Meditech Blog     

                                                                                                                                                                                                          

Comments

Currently, there are no comments. Be the first to post one!
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics