Advice - indexing on varchar fields where only last x characters known - Mailing list pgsql-sql

From Gary Stainburn
Subject Advice - indexing on varchar fields where only last x characters known
Date
Msg-id 201310171220.44550.gary.stainburn@ringways.co.uk
Whole thread Raw
Responses Re: Advice - indexing on varchar fields where only last x characters known  (Jayadevan M <maymala.jayadevan@gmail.com>)
Re: Advice - indexing on varchar fields where only last x characters known  (skinner@britvault.co.uk (Craig R. Skinner))
Re: Advice - indexing on varchar fields where only last x characters known  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Re: Advice - indexing on varchar fields where only last x characters known  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: Advice - indexing on varchar fields where only last x characters known  (David Johnston <polobo@yahoo.com>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: skinner@britvault.co.uk (Craig R. Skinner)
Date:
Subject: Re: PostgreSQL 9.2 tstzrange null/infinity CONSTRAINT CHECK
Next
From: Jayadevan M
Date:
Subject: Re: Advice - indexing on varchar fields where only last x characters known