Skip to content

Add projects path index

Fixes performance regression introduced by !1649 (merged)

One thing to consider is whether this should be unique the same way as is it for namespaces.path:

I think that no: But, when I look at validation in models/project.rb:

validates :path,
    presence: true,
    length: { within: 0..255 },
    format: { with: Gitlab::Regex.project_path_regex,
              message: Gitlab::Regex.project_path_regex_message }

Compared to models/namespace.rb:

validates :path,
    uniqueness: { case_sensitive: false },
    presence: true,
    length: { within: 1..255 },
    exclusion: { in: Gitlab::Blacklist.path },
    format: { with: Gitlab::Regex.namespace_regex,
              message: Gitlab::Regex.namespace_regex_message }

Comments from @jacobvosmaer:

jacobvosmaer [8:07 PM]
adding uniqueness on a whim is probably not a good idea

jacobvosmaer [8:07 PM]
@kamilt: I see it now, there is a scope problem

jacobvosmaer [8:07 PM]
the path has to be unique in the namespace

jacobvosmaer [8:08 PM]
`  validates_uniqueness_of :path, scope: :namespace_id`

jacobvosmaer [8:09 PM]
@kamilt: I suggest to add a non-unique index on path now, and then look into adding a combined unique index on path,namespace_id later (8.2)

/cc @DouweM @jacobvosmaer @rspeicher

Merge request reports

Loading