Monday, September 3, 2018

SQL Server Format command (TSQL)

If you're going to use the SQL Server format command, please consider about it's performance hit. When compare it with the cast, and convert you can feel a big performance difference. It drags your query compilation comparably slow.

"format()" command is a really convince to use, but end result is bit scary.
With my experience, query that i wrote with the format takes around 30 sec, and the same query took only 11 sec without the format command.

i used it as follows (This is an example only)
Select format(getdate(),'yyyy-MM-dd')

replace with

Select cast(getdate() as date)

No comments:

Post a Comment

Postgress - Read a XML file from a postgress table XML column

SELECT xmltable.* FROM xmldata, XMLTABLE('//ROWS/ROW' PASSING data COLUMNS id int PATH ...