Re: Advice - indexing on varchar fields where only last x characters known

Поиск
Список
Период
Сортировка
От Gavin Flower
Тема Re: Advice - indexing on varchar fields where only last x characters known
Дата
Msg-id 52602BF9.7020403@archidevsys.co.nz
обсуждение исходный текст
Ответ на Advice - indexing on varchar fields where only last x characters known  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Список pgsql-sql
On 18/10/13 00:20, Gary Stainburn wrote:
> I have a problem with a field that appears on a number of my tables.
>
> The field is the Vehicle Identification Number. Every vehicle has one and it
> uniquely identifies that vehicle.
>
> Traditionally this was a 11 character string but a number of years ago was
> extended to 17 characters by adding a 6 character prefix.
>
>
> The problem that I have is that these VIN numbers are provided by a number of
> data systems including manufacturer feeds, logistics companies as well as
> internal systems. Some use the full 17 character string while others only use
> the last 11.
>
> On top of this, my users are used to only having to type the last 6 characters
> for speed and usability reasons.
>
> However, it means that every time I'm trying to connect various tables up
> using foreign keys or doing searches I have to make allowences for this which
> means I'm using things like substring, like, regex etc. all of which are very
> slow.
>
> Can anyone suggest a better / more efficient way of handling these.
>
> Gary
>
>
Use 2 fields, one for the 6 character prefix, and the other for the 
original 11 digits.

Search for the 6 character prefix, or a null prefix AND the first 6 
characters of the 11 digit field.

It might be better to have a string for the prefix and make it blank 
rather than null, when nothing is entered there.


Cheers,
Gavin





В списке pgsql-sql по дате отправления:

Предыдущее
От: skinner@britvault.co.uk (Craig R. Skinner)
Дата:
Сообщение: Re: Advice - indexing on varchar fields where only last x characters known
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Advice - indexing on varchar fields where only last x characters known