question

David 2 1 avatar image
David 2 1 asked

Improving Performance on Computed Column?

Hi there, What is the best method to improve the query performance on a computed column? For example I have a simple table with ~16,000 rows however when I remove the following computed column from the query it returns the results in half the time: CREATE TABLE TEST_TBL( ID INT IDENTITY (1,1) NOT NULL, DATA_ZIP VARBINARY(MAX), DATA_JSON VARBINARY(MAX), JSON AS (CONVERT(NVARCHAR(MAX),DATA_JSON)) ) I'm struggling to improve performance on this table. TIA
tsqlperformancecomputed-column
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
anthony.green avatar image
anthony.green answered
Try changing the computed column to persisted, that will force the conversion to be stored in the table, rather than having to convert it on the fly with each select.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David 2 1 avatar image David 2 1 commented ·
Thanks for confirming.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.