[
https://issues.apache.org/jira/browse/DERBY-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12535435
]
Anurag Shekhar commented on DERBY-2212:
---------------------------------------
thanks Mike for revisiting the issue.
I felt letting the index remain unique will be better because
1. It avoids the need of rescanning the index to check for duplicates after
every update/insert.
2. Marking the index as non unique will cause optimizer to conclude that there
might be
duplicate records for equal predicates (not just IS NULL case) and hence it may
some
times select a genuine non unique index when it could have selected this
(almost unique)
index. Right now (in this patch) only if there is a IS NULL in where clause
optimizer considers
it to have multiple records.
Many internal routine don't use optimizer to look for records but directly
calls out to internal store
methods (like the case of drop table). In such cases changes will be required
irrespective of
the approach we use.
> Add "Unique where not null" to create index
> -------------------------------------------
>
> Key: DERBY-2212
> URL: https://issues.apache.org/jira/browse/DERBY-2212
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 10.2.1.6
> Reporter: Oleksandr Alesinskyy
> Assignee: Anurag Shekhar
> Attachments: derby-2212preview.diff, derby-2212preview2.diff
>
>
> Derby prohibits creation of unique constraints on nullable colums (as well if
> only some columns in the constraint list are nullable) and treat nulls in
> unique indexes as normal values (i.e. only one row with null values in
> indexed columns may be inserted into the table). This bahavior is very
> restrictive, does not completely comply with SQL standards (both letter and
> intent) as well as with business needs and intending meaning of NULL values
> (2 null values are not considered as equal, this comparision shall return
> NULL, and for selection criteria boolean null is treated as FALSE).
> This behavior, as far as I can see, is modelled after DB2 (and differs from
> behavior of most other major databases, like SyBase, Oracle, etc.).
> But even DB2 provide some means to alleviate these restrictions, namely
> "UNIQUE WHERE NOT NULL" clause for CREATE INDEX statement.
> It will be very good if such "UNIQUE WHERE NOT NULL" clause will be
> introduced in Derby.
> Regards,
> Oleksandr Alesinskyy
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.