Open knz opened 7 years ago
@knz Is it a common use case to leverage a database to do computations that it will not store? I realize that it's possible, but curious what the percentage of users are that will actually leverage CockroachDB in this way.
Yes we do this all the time in SELECT queries!
The computation in a SELECT can produce values of any data type not only column types.
@knz I think that my point is moreso that the common use case of CockroachDB is storing data and not using it for ad-hoc computation through SELECT
. Reframing all of the documentation around data types to express an edge case feels too aggressive. The point you're bringing up is salient and important to document; I just want to ensure that we're focusing on how most people will actually interact with the database, and handling uncommon use cases with auxiliary notices (e.g. notes).
My point is that the majority of SQL requests from clients will be SELECT statements, and that more than 99% of all expressions ever evaluated by CockroachDB will be to compute values for clients and never reach the database.
Do not let the incidental fact that you personally had to fabricate a lot of INSERT statement to generate your tests and examples bias you from realizing that the majority of interactions with a SQL database happens via SELECT and its rendered expressions.
@knz, thanks for asking us to revisit this. It'll be helpful to read over your expressions docs before proceeding on reworking the data type pages, which, you're right, do focus on column types. Also, in the meantime, I'm going to look at how other databases handle this in their docs.
Do you have a full list of data types that are not supported as column types, aside from tuples?
Data types that cannot be stored:
generate_series(...)
.
You can have a table as the result of a single value expression. These obviously cannot be inserted into a single table cell, nor (currently) returned to the client, but they can appear as an intermediate value, for example in array(generate_series(1,32))
.Column types that cannot be produced by expressions: SERIAL, BIGINT, INT4, INT8, BYTEA, BLOB, VARCHAR, TEXT, possibly others.
We have closed this issue because it is more than 3 years old. If this issue is still relevant, please add a comment and reopen the issue. Thank you for your contribution to CockroachDB docs!
Raphael 'kena' Poss (knz) commented:
Currently all the pages for individual data types
int.md
string.md
etc conflate data type and column type.In particular they miss the distinction between "inserting a value into a column of a given column type" from "computing a value of a given data type".
This distinction is especially important because:
Steps to improve:
Jira Issue: DOC-97