Skip to content

Slow SQLite query in kine #82

@miro-balaz

Description

@miro-balaz

I was doing a test, and found that SQL query

listSQL = fmt.Sprintf(`
		SELECT %s
		FROM kine AS kv
			LEFT JOIN kine kv2 
				ON kv.name = kv2.name
				AND kv.id < kv2.id
		WHERE kv2.name IS NULL
			AND kv.name >= ? AND kv.name < ?
			AND (? OR kv.deleted = 0)
			%%s
		ORDER BY kv.id ASC
	`, columns)

from

https://github.com/canonical/kine/tree/v0.4.1-k8s-dqlite.9

performs very badly in situations where there are many rows with the same name. I do not know how long it takes, I stopped it after few seconds. I think it might have quadratic complexity. This situation can arise in k8s after some problems. That is how I discovered it.

Is this something that is known? Are there any plans to change it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions