【发布时间】:2010-12-01 19:55:59
【问题描述】:
好的 SQL Server 大师,启动你的分析器。
- 我在应用程序内存中有一个标题列表(大约 250 个)。
- 我有一个数据库表“books”,其中包含超过一百万条记录,表的一列是“title”并且类型为 nvarchar。
- “books”表还有一个名为“ISBN”的列
- books.title 不是主键,不是唯一的,但已编入索引。
所以我想知道哪个更有效:
WITH titles AS (select 'Catcher and the Rye' as Title
union all 'Harry Potter ...'
...
union all 'The World Is Flat')
select ISBN from books, titles where books.title = titles.title;
或者:
select ISBN from books where title in ('Catcher and the Rye','Harry Potter',...,'The World Is Flat');
或者:
???
【问题讨论】:
标签: sql sql-server sql-server-2005 performance tsql