473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Mini Index?

I have a table with a few million records and I need to search and
return rows where a varchar(1000) field has the value "Showed"

SQL will not allow me to add an index for a field of this length.

Is it possible to create some kind of index for only the value "Showed"
Or is there some other faster way to search for this value?

thanks,
Paul

Dec 2 '05 #1
8 1439
SQL
Take a look at full-text indexing look it up in BOL

http://sqlservercode.blogspot.com/

Dec 2 '05 #2
you can use a computed column
IsShowed as case when yourColumn = 'Showed' then 1 end

and create an index on IsShowed

Dec 2 '05 #3
Hi Alexander,

I tried a computed column, but then all the users of the windows
application that is the front end of this database got errors when
trying to insert a record into this table. Is there anything more I
have to do to use a computed column?

thanks,
Paul

Alexander Kuznetsov wrote:
you can use a computed column
IsShowed as case when yourColumn = 'Showed' then 1 end

and create an index on IsShowed


Dec 5 '05 #4
On 5 Dec 2005 08:36:22 -0800, pa********@gmail.com wrote:
Hi Alexander,

I tried a computed column, but then all the users of the windows
application that is the front end of this database got errors when
trying to insert a record into this table. Is there anything more I
have to do to use a computed column?

thanks,
Paul


Hi Paul,

All INSERT statements should always include a column list. There are
many reasons for this - you just found one of them!

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Dec 5 '05 #5
(pa********@gmail.com) writes:
I tried a computed column, but then all the users of the windows
application that is the front end of this database got errors when
trying to insert a record into this table. Is there anything more I
have to do to use a computed column?


Sounds like a case of poor application design.

An alternative is to use an indexed view instead. The view would look
like:

CREATE VIEW showed_view WITH SCHEMABINDING AS
SELECT pkcol
FROM tbl
WHERE yourcolumn = 'Showed'

You would then have to use this view in your queries. (In theory SQL Server
could use the view even if you query the table directly, but it does not
always happen.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 5 '05 #6
Paul,

besides using an indexed view, which may be a little bit tricky, you
could create your own table:

SELECT pkcol
FROM tbl
into side_table
WHERE yourcolumn = 'Showed'

of course you will have to maintain the table manually, via triggers.

Dec 7 '05 #7
You know I had tried that seperate table with an insert trigger, but
again the windos app didn't like it, and unfortuanately I don't have
control over the windows app. I didn't see how you can put an index on
a view...am i missing something?

thanks,
paul

Dec 8 '05 #8
(pa********@gmail.com) writes:
You know I had tried that seperate table with an insert trigger, but
again the windos app didn't like it, and unfortuanately I don't have
control over the windows app. I didn't see how you can put an index on
a view...am i missing something?


Read about it under the CREATE VIEW and CREATE INDEX statements in the
T-SQL reference. The view must be created WITH SCHEMABINDING, and all
notations must be two-part: dbo.tbl. There are a couple of more
restrictions, which is why I refer you to the manual.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 8 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Carlos Ribeiro | last post by:
I'm doing some experiments with mini declarative languages (as explained by David Mertz in http://www-106.ibm.com/developerworks/library/l-cpdec.html) in Python, with the intention to use it as...
181
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ...
9
by: Emmanuel Charruau | last post by:
Hi, I am looking for a class or any information which would allow me to make communicate mini-module in c++. I have been looking on the net for some examples of such implementation, but I did...
0
by: tbatwork828 | last post by:
VS 2005. I have compiled my dlls/exes in Release mode and also setting Debug Info="full"under Project - Properties - Build - select "Release" under "Configuration" drop down - the Advanced button...
3
by: aurora | last post by:
This is an entry I just added to ASPN. It is a somewhat novel technique I have employed quite successfully in my code. I repost it here for more explosure and discussions. ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: Hollywood | last post by:
Hello dear members of the comp.lang.javascript newsgroup. I'm building the "Contact Us" section of my .mobi site (xhtml and html). Is there any way to create an e-mail form that use the...
5
by: =?Utf-8?B?R3VpbmVhcGln?= | last post by:
Hi, I just wrote a mini C# lab for myself, I think it may be useful for others, so I shared it on my blog. If you often need to write only serveral lines of code and don't want to waste time on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.