17 Commits

Author SHA1 Message Date
Sven Klemm
f680b99529 Fix assertion in calculate_chunk_interval for negative target size
When called with negative chunk_target_size_bytes
calculate_chunk_interval will throw an assertion. This patch adds
error handling for this condition. Found by sqlsmith.
2023-03-07 14:50:57 +01:00
Fabrízio de Royes Mello
a4356f342f Remove trailing whitespaces from test code 2022-11-18 16:31:47 -03:00
Sven Klemm
110d77a2fe Combine test files
Merge test files that after the removal of PG11 support need
to be no longer version specific.
2021-06-01 20:21:06 +02:00
Erik Nordström
f633b19266 Make adaptive chunking test work for PG12
PostgreSQL 12 introduced space optimizations for indexes, which caused
the adaptive chunking test to fail since its measure of chunk size
includes indexes that now report different sizes.

To fix this, the adaptive chunking test now has version-specific
output files.
2020-04-14 23:12:15 +02:00
Sven Klemm
5427bccf01 Remove byte sizes from chunk_adaptive test
The byte sizes for tables/indexes differ between 32 bit and 64 bit
so this patch removes them from the test output.
2019-11-06 11:17:58 +01:00
Matvey Arye
0670610f1c Improve permission checks
This tests and/or improves permission checks for:

-create index multi-transaction
-set_adaptive_chunking
-timescaledb_pre_restore
-timescaledb_post_restore
2019-06-24 10:57:38 -04:00
Sven Klemm
f89fd07c5b Remove year from SQL file license text
This changes the license text for SQL files to be identical
with the license text for C files.
2019-01-13 23:30:22 +01:00
Sven Klemm
787cc0470e Replace hardcoded database name from regression tests
Replace hardcoded database name from regression tests with :TEST_DBNAME
Remove creation of database single_2 from test runner and add it to
bgw_launcher and loader test since no other tests used those
use SQL comments in test scripts
2018-12-28 19:26:27 +01:00
Sven Klemm
46d3479757 Add tests for calling functions with NULL arguments 2018-11-23 20:54:27 +01:00
Joshua Lockerman
20ec6914c0 Add license headers to SQL files and test code 2018-10-29 13:28:19 -04:00
Amy Tai
46564c1e06 Handle ALTER SCHEMA RENAME properly
Previously, we did not intercept the ALTER SCHEMA [name] RENAME command, which meant all Timescale catalog tables that store a schema name were not getting updated properly. This caused problems when users tried to drop a hypertable in a renamed schema, but also would have also caused problems with other commands (which we now add tests for in this PR).
2018-10-12 16:25:22 -04:00
Rob Kiefer
d09405d2b3 Fix adaptive chunking when hypertables have multiple dimensions
The use of the incorrect index to find the hypertable that a
dimension belongs to caused adaptive chunking to break whenever
dimension_id != hypertable_id, which happened with hypertables that
have multiple dimensions where time is not the first one.
2018-09-21 10:21:57 -04:00
Rob Kiefer
d5a639263e Fix adaptive chunking so it chooses correct index
Previously our check that the index matched the type of the index
was incorrect, using attno instead of atttypid. However, this also
had a problem in that if there was another column with the same
type as the time column, e.g., two BIGINT columns, we could pick
the wrong index to use to find min and max. The check now makes
sure the type is correct AND the name is the same as the table
column name.
2018-09-19 14:06:03 -04:00
Erik Nordström
148f2da924 Use shared_buffers as the available cache memory
When configuring adaptive chunking and estimating the
chunk_target_size, we should use shared_buffers as an indication of
cache memory instead of trying to estimate based on
effective_cache_memory, system memory or other settings. This is
because shared_buffers should already have been set by the user based
on system memory, and also accurately reflects the cache memory
available to PostgreSQL.

We use a fraction (currently 0.9) of this cache memory as the
chunk_target_size. This assumes no concurrency with other hypertables.
2018-08-08 17:01:31 +02:00
Erik Nordström
d81dccbb63 Set the default chunk_time_interval to 1 day with adaptive chunking enabled
When adaptive chunking is enabled, and no `chunk_time_interval` is
set, it is better to start with a small chunk size rather than a too
big, since it will adapt faster. This change sets the
`chunk_time_interval` to 1 day if adaptive chunking is enabled on a
hypertable. Note that this only happens if adaptive chunking is
enabled when `create_hypertable()` is called. Otherwise, the existing
`chunk_time_interval` will be used.
2018-08-08 17:01:31 +02:00
Erik Nordström
2e7b32cd91 Add WARNING when doing min-max heap scan for adaptive chunking
Adaptive chunking uses the min and max value of previous chunks
to estimate their "fill factor". Ideally, min and max should be
retreived using an index, but if no index exists we fall back
to a heap scan. A heap scan can be very expensive, so we now
raise a WARNING if no index exists.

This change also renames set_adaptive_chunk_sizing() to simply
set_adaptive_chunking().
2018-08-08 17:01:31 +02:00
Erik Nordström
9c9cdca6d3 Add support for adaptive chunk sizing
Users can now (optionally) set a target chunk size and TimescaleDB
will try to adapt the interval length of the first open ("time")
dimension in order to reach that target chunk size. If a hypertable
has more than one open dimension, only the first one will have a
dynamically adapting interval.

Users can optionally specify their own function that calculates the
new dimension interval. They can also set a target size of 0 in order
to estimate a suitable target size for a chunk based on available
memory.
2018-08-08 17:01:31 +02:00