Skip to content

Commit

Permalink
feat: limit the time period used in tag values queries
Browse files Browse the repository at this point in the history
Add a time interval limit when populating a tag values menu, this
is to avoid the need to process the entire measurement.
  • Loading branch information
mhilton committed Mar 13, 2024
1 parent 167c4c6 commit 46c5deb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dataExplorer/context/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CACHING_REQUIRED_END_DATE,
CACHING_REQUIRED_START_DATE,
} from 'src/utils/datetime/constants'
import {DEFAULT_LIMIT} from 'src/shared/constants/queryBuilder'
import {DEFAULT_INTERVAL, DEFAULT_LIMIT} from 'src/shared/constants/queryBuilder'
import {LanguageType} from 'src/dataExplorer/components/resources'

// Contexts
Expand Down Expand Up @@ -214,6 +214,7 @@ export const TagsProvider: FC<Prop> = ({children, scope}) => {
const queryTextSQL: string = `
SELECT DISTINCT("${tagKey}")
FROM "${measurement}"
WHERE time < NOW() AND time >= NOW() - INTERVAL '${DEFAULT_INTERVAL}'
ORDER BY "${tagKey}"
LIMIT ${DEFAULT_LIMIT}
`
Expand Down
1 change: 1 addition & 0 deletions src/shared/constants/queryBuilder.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const DEFAULT_LIMIT = 1000
export const DEFAULT_INTERVAL = '1 day'

0 comments on commit 46c5deb

Please sign in to comment.