[Cubicweb] unique constraint on unlimited String attribute
sylvain.thenault at logilab.fr
Thu Jun 16 15:59:59 CEST 2016
On 16 juin 15:03, Julien Cristau wrote:
> On Thu, Jun 16, 2016 at 14:25:50 +0200, Sylvain Thénault wrote:
> > Hi there,
> > a while ago I added a unique constraint on cwuri in cubicweb. I've just
> > discovered today that it has been removed by 1ee631aedf2f. So I'm wondering: is
> This doesn't seem to be the changeset you're talking about, but rather
> its child, 48e54aabcd5544945938092f7cf1d39f71b64fb2.
> > it really a bad habit to add UNIQUE on unlimited string? I remember being
> > advised to never set size constraint on string on postgres for instance...
> Indices on unlimited string columns are not supported by sql server, at
> least, and in general it seems questionable from a design and
> performance pov to want to search on such a field (except using full
> text search).
> I guess one option is to have an extra computed column with a (fixed
> size) hash of your nvarchar(max) column, and index *that*, but
> reconsidering either the index or the lack of size limit might be
Well in case of a column such as cwuri, I think its hard to set a limit, though
the I would expect it to be of a "reasonable size" enough to be indexed.
In the case of e.g. postgres, it seems that adding the size limit will only slow
down insert performance.
Beside saying "damned sqlserver", I'm not sure about the next move. It seems the
easiest way would be to set a high-enough limit on cwuri. Anyone?
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
CubicWeb, the semantic web framework: http://www.cubicweb.org
More information about the Cubicweb