22 Commits

Author SHA1 Message Date
Alexander Kuzmenkov
fd66f5936a Warn about mismatched chunk cache sizes
Just noticed abysmal INSERT performance when experimenting with one of
our customers' data set, and turns out my cache sizes were
misconfigured, leading to constant hypertable chunk cache thrashing.
Show a warning to detect this misconfiguration. Also use more generous
defaults, we're not supposed to run on a microwave (unlike Postgres).
2023-02-14 19:32:41 +04:00
Sven Klemm
dbb9988eee Fix result ordering in tests
This patch fixes the result sorting in tests that had no ORDER BY
clause or where ORDER BY clause did not result in fixed ordering.
2020-09-28 12:15:42 +02: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
Joshua Lockerman
20ec6914c0 Add license headers to SQL files and test code 2018-10-29 13:28:19 -04:00
Erik Nordström
71962b86ec Refactor dimension-related API functions
The functions for adding and updating dimensions have been refactored
in C to:

- improve usage of proper error codes
- make messages that better conform with the PostgreSQL standard.
- improve security by avoiding that lots of code run under SECURITY DEFINER

A new if_not_exists option has also been added to add_dimension() and
a the number of partitions can now be set using the new
set_number_partitions() function.

A bug in the validation of smallint time intervals has been fixed. The
previous code didn't check for intervals > 0 and smallint intervals
accepted values up to UINT16_MAX instead of INT16_MAX.
2018-01-25 19:02:34 +01:00
Matvey Arye
25f3284466 Handle cache invalidation during subtxn rollback
Add logic to invalidate the cache during subtxn rollback.

Fixes #376
2018-01-11 09:35:37 -05:00
Matvey Arye
ad7d361418 Better accounting for number of items stored in a subspace
We add better accounting for number of items stored in a subspace
to allow better pruning. Instead of pruning based on the number of
dimension_slices in subsequent dimensions we now track number of total
items in the subspace store and prune based on that.

We add two GUC variables:
1) max_open_chunks_per_insert (default work_mem in bytes / 512. This
assumes an entry is 512 bytes)
2) max_cached_chunks_per_hypertable (default 100). Maximum cached chunks per
hypertable.
2018-01-10 13:50:36 -05:00
Rob Kiefer
00a096f2f6 Modify tests to make more platform agnostic
When testing on Windows these tests were returning differences
because of floating point (sql_query_results_*) differences and
because the cost was trivially higher (insert_single). Here we
remove the costs since it was not relevant to the regressions we
want to detect. Further we truncate the floating point averages
to 8 decimal places; enough to see significant differences.
2017-12-09 12:54:01 -05:00
Matvey Arye
9c7191e898 Change TIMESTAMP partitioning to be completely tz-independent
Previously, for timezones w/o tz. The range_end and range_start were
defined as UTC, but the constraints on the table were written as as
the local time at the time of chunk creation. This does not work well
if timezones change over the life of the hypertable.

This change removes the dependency on local time for all timestamp
partitioning. Namely, the range_start and range_end remain as UTC
but the constraints are now always written in UTC too. Since old
constraints correctly describe the data currently in the chunks, the
update script to handle this change changes range_start and range_end
instead of the constraints.

Fixes #300.
2017-11-20 09:27:30 -05:00
Matvey Arye
291050b395 Change DATE partitioning to be completely tz-independent
The insert logic in time_value_to_internal was not tz independent,
causing problems with date in some timezones. This is now fixed.

Fixes #306.
2017-11-17 12:08:40 -05:00
Erik Nordström
500563ffe5 Add support for PostgreSQL 10
The extension now works with PostgreSQL 10, while
retaining compatibility with version 9.6.

PostgreSQL 10 has numerous internal changes to functions and
APIs, which necessitates various glue code and compatibility
wrappers to seamlessly retain backwards compatiblity with older
versions.

Test output might also differ between versions. In particular,
the psql client generates version-specific output with `\d` and
EXPLAINs might differ due to new query optimizations. The test
suite has been modified as follows to handle these issues. First,
tests now use version-independent functions to query system
catalogs instead of using `\d`. Second, changes have been made to
the test suite to be able to verify some test outputs against
version-dependent reference files.
2017-11-10 09:44:20 +01:00
Matvey Arye
5cee104d57 Allow chunk_time_interval to be specified as an INTERVAL type 2017-09-15 12:48:14 -04:00
Matvey Arye
c3b6fb90d9 Fix bug with negative dimension values
Previously, negative dimension values had an off-by-one bug where the
wrong chunk was created for points on chunk borders. This PR fixes that.
2017-08-28 10:29:05 -04:00
Rob Kiefer
2a51cf0701 Add support for negative values in dimension range
Previously dimension_slice would only allow ranges to start and
end with values >= 0. However, this did not allow for timestamps
prior to 1970 because those times would be represented by negative
integers. With this PR we now support dates prior to 1970.

Addresses issue #153.
2017-08-18 11:28:11 -04:00
Rob Kiefer
f3df02d50c Improve handling of non-TIMESTAMP/TZ timestamps
Previously the default chunk time in microseconds was too large
for a SMALLINT or INTEGER field. Now, we only assign a default
value if the type is TIMESTAMP or TIMESTAMPTZ. Integer timestamps,
such as SMALLINT, INTEGER, and BIGINT, need to be explicitly set
since only the user knows what units the numbers represent.

Further, we check to make sure the chunk time interval is not too
large for SMALLINT and INTEGER so as to avoid confusing problems
later when the user goes to insert.
2017-08-17 12:13:00 -04:00
Erik Nordström
2200010ddb Fix EXPLAIN and PREPAREd statements on INSERTs
This fixes some issues that caused EXPLAIN and PREPAREd statements to
fail on INSERTs. The plan modification on INSERTs passed on a plan
node to the execution stage. However, that plan node pointer becomes
invalid when the plan is copied, as happens with prepared
statements. The fix required another modification to the plan by
wrapping also the ModifyTable plan node. This wrapping is necessary to
access the plan state node (ModifyTableState) on execution. Having
access to the ModifyTableState node is necessary to set the correct
arbiter index list for ON CONFLICT statements.

This change also fixes the output of EXPLAIN to properly show the plan
tree, and performs some cleanups.
2017-07-31 16:18:40 +02:00
Erik Nordström
696cc4c4f1 Provide API for adding hypertable dimensions
A new public-facing API `add_dimension(table, column, ...)`
makes it possible to add additional dimensions (partitioning
columns) to a hypertable.

Currently, new dimension can only be added to empty tables.

The code has also been refactored with a corresponding
internal function that is called by both `add_dimension()`
and `create_hypertable()`.
2017-06-27 19:39:14 +03:00
Matvey Arye
f960c24cd4 Fix bug with querying a row as a composite type
Previously a query like `SELECT "1dim" FROM "1dim"` on a hypertable would
fail since the change_table_walker did not properly change the types on
whole row vars. That is now fixed.
2017-05-12 13:39:39 -04:00
Matvey Arye
b128ac2a87 Fix bug with INSERT INTO...SELECT
Previously, INSERT INTO...SELECT FROM hypertable was broken. This was
caused by incorrectly tracking the commandType in change_name_walker.
Fixes #24.
2017-05-03 13:37:23 -04:00
Robin Thomas
72f754a576 use PostgreSQL's own hash_any function as default partfunc;
remove all murmur3-related source code. Alter regression tests
to reflect new hash values for inputs, and a slightly different
set of input data to ensure that sufficient chunks and partitions
are tested. Some changes to .sh scripts in sql/setup that seem
to be used only to power the "unit tests", which I cannot
yet run successfully.
2017-04-29 18:31:44 -04:00
Erik Nordström
9023de61db Cleanup tests and make errors less verbose
Previously, each test set their own (although mostly the same)
configuration for log output and error verbosity. This is now set
globally in the test runner so that tests only need to set these
configuration parameters if they need to override the defaults.  The
log verbosity is also reduced so that errors aren't generated with the
line number of the source file that output the error. Line numbers in
the output can break tests when upgrading to a new PostgreSQL version
that outputs a different line number.
2017-03-23 22:56:03 +01:00
Erik Nordström
7b94c573ba Refactor directory structure and tests
- Directory structure now matches common practices
- Regression tests now run with pg_regress via the PGXS infrastructure.
- Unit tests do not integrate well with pg_regress and have to be run
  separately.
- Docker functionality is separate from main Makefile. Run with
  `make -f docker.mk` to build and `make -f docker.mk run` to run
  the database in a container.
2017-01-31 20:14:19 +01:00