Tag Info

New answers tagged

1

Have you tried using ranges? Maythe the indexing methods for them (gist) can give you desired performance (for large datasets). Though gist indexes come with some tradeoffs (size, build-time, index-time for simple queries). Some testing code: create table t(id serial primary key, some_col text, foo numrange); insert into t(some_col, foo) select 'foobar', ...


3

if in a row col1 is greater then or equal two col1 in another row, then the same relation is valid between the two corresponding col2 entries In which case you can reformulate your query to look like: SELECT * FROM table WHERE col2 >= val1 AND col2 <= val2; because you can find the lower bound for col2 from the lower bound for col1, like this: ...


0

For followers, I had a similar problem that was like select * from table where bigint_column between x and y and mod(bigint_column, 10000) == z The problem was that my bigint_column "between x and y" had an index, but my query was basically "all the rows" in that table, so it wasn't using the index [since it had to scan the entire table anyway] but was ...


9

If a user executes a statement that is one of the statements in the multi-statement query can it use that relevant part of the query plan already in the cache for the multi-statement query? No. The basic unit of plan reuse in SQL Server is the batch. Would it be better to hash each statement in a multi-statement query so they could be used by users ...



Top 50 recent answers are included