0

I have a table that stores a tree like structure of file names. There are currently 8 million records in this table. I am working on a way to quickly find a list of files what have a specific serial number embedded in the name.

FS_NODES
-----------------------------------
NODE_ID              bigint PK
ROOT_ID              bigint
PARENT_ID            bigint
NODE_TYPE            tinyint
NODE_NAME            nvarchar(250)
REC_MODIFIED_UTC     datetime
REC_DELETION_BIT     bit

Example file name (as stored in the node_name):
scriptname_SomeSerialNumber_201205240730.xml

As expected, the LIKE statement to find the files takes several minutes to scan the entire table and would like to improve this. There is no consistent patterns for the names as each developer likes to create their own naming convention.

I tried using the Full Text Search and really love the idea but not able to get it to find files based off keywords in the name. I believe the problem is due to the underscores.

Any suggestions on how I can get this to work? I am using a neutral language for the catalog.

@@VERSION
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) 
Nov 24 2008 13:01:59 
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)

Is there a way to alter the catalog and split the keywords out manually? Thank you!

4

1 に答える 1

1

全文検索は答えではありません。部分的な文字列の一致ではなく、単語に使用されます。あなたがすべきことは、このテーブルにデータを挿入または更新するときに、将来の検索に関連するファイル名の部分を、索引付けできる独自の列に抽出することです。結局のところ、これらは使用方法によっては別個のデータです。開発者がやりたいことを何でもできるようにするのではなく、より予測可能な命名規則を適用することも検討できます。

ユーザー要求ごとに編集:

REPLACE(filename, '_', ' ') である計算列を追加します。または、計算された列の代わりに、既存のデータを手動で入力し、挿入手順を変更して今後に対処する列だけです。または、それらを関連テーブルの個別の行に分割することもできます。

于 2012-05-24T13:57:44.417 に答える