Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add new indexes & rework distinct #449

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions .goreleaser-darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ archives:
format_overrides:
- goos: windows
format: zip
name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}"
replacements:
amd64: 64bit
386: 32bit
arm: ARM
arm64: ARM64
darwin: macOS
linux: Linux
windows: Windows

name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}

checksum:
name_template: 'checksums-darwin.txt'
Expand All @@ -51,7 +48,7 @@ snapshot:
name_template: "{{ .Tag }}"

brews:
- tap:
- repository:
owner: formancehq
name: homebrew-tap
name: numary
Expand Down
16 changes: 7 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ archives:
format_overrides:
- goos: windows
format: zip
name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}"
replacements:
amd64: 64bit
386: 32bit
arm: ARM
arm64: ARM64
darwin: macOS
linux: Linux
windows: Windows
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}


checksum:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--statement
CREATE INDEX IF NOT EXISTS postings_array_length_src ON "VAR_LEDGER_NAME".postings (jsonb_array_length(source));
--statement
CREATE INDEX IF NOT EXISTS postings_array_length_dst ON "VAR_LEDGER_NAME".postings (jsonb_array_length(destination));
--statement
CREATE INDEX IF NOT EXISTS accounts_array_length ON "VAR_LEDGER_NAME".accounts (jsonb_array_length(address_json));
--statement
CREATE INDEX IF NOT EXISTS volumes_array_length ON "VAR_LEDGER_NAME".volumes (jsonb_array_length(account_json));
8 changes: 6 additions & 2 deletions pkg/storage/sqlstorage/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ func (s *Store) buildTransactionsQuery(flavor Flavor, p ledger.TransactionsQuery
metadata = p.Filters.Metadata
)

sb.Select("id", "timestamp", "reference", "metadata", "postings", "pre_commit_volumes", "post_commit_volumes").
Distinct()
if flavor == SQLite {
sb.Select("id", "timestamp", "reference", "metadata", "postings", "pre_commit_volumes", "post_commit_volumes").
Distinct()
} else {
sb.Select("distinct on (id) id", "timestamp", "reference", "metadata", "postings", "pre_commit_volumes", "post_commit_volumes")
}
sb.From(s.schema.Table("transactions"))
if (source != "" || destination != "" || account != "") && flavor == PostgreSQL {
// new wildcard handling
Expand Down