SELECTing DISTINCT

  • One performance reated question guys:

    Is there any difference between submitting a dynamic SQL query "SELECT DISTINCT fieldname FROM sometable" and creating a view that uses this SQL and then submitting "SELECT fieldname from someview"

  • This was removed by the editor as SPAM

  • No functional difference. I think the view might be very marginally faster if you're doing this lots, since it will cache the query access plan for the view. In my opinion you'd be better off without the view as it's simpler. Or think about using a stored procedure to hide the implementation from the client.

  • I suggest you using the view than dynamic query. One reason is that the view has been compliled, as Rory said. Another reason is view can provide you more features when your request become complex. You won't alway submit a query as simple as the statement you noted here actually

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply