Questions tagged [limits]
79 questions
25
votes
4 answers
How to limit maximum number of rows in a table to just 1
I have a configuration table in my SQL Server database and this table should only ever have one row. To help future developers understand this I'd like to prevent more than one row of data being added. I have opted to use a trigger for this, as…
Dib
- 437
- 1
- 5
- 11
19
votes
2 answers
MongoDB terminates when it runs out of memory
I have the following configuration:
a host machine that runs three docker containers:
MongoDB
Redis
A program using the previous two containers to store data
Both Redis and MongoDB are used to store huge amounts of data. I know Redis needs to…
Simone Bronzini
- 293
- 1
- 2
- 6
18
votes
1 answer
"Limit 1000,25" vs "limit 25 Offset 1000"
Recently I've found out that MySQL has a offset feature. I've been trying to find documentation about the results of offset, or the difference in between offset and the limit variant, but I can't seem to find what I'm looking for.
Lets say I have…
Martijn
- 283
- 1
- 2
- 8
16
votes
5 answers
SQL Server Error 8632 due to over 100,000 entries in WHERE clause
My problem (or at least the error message) is very similar to query processor ran out of internal resources - extremely long sql query.
My customer is working with an SQL select-query, containing a where-clause with exactly 100,000 entries.
The…
Dominique
- 295
- 1
- 2
- 8
12
votes
1 answer
ANSI/ISO plans for LIMIT standardization?
Are there currently plans to standardize one best way of limiting the number of results returned by a query?
The stack overflow question at Is there an ANSI SQL alternative to the MYSQL LIMIT keyword? lists the various ways to handle this behavior…
chucksmash
- 515
- 1
- 5
- 9
11
votes
1 answer
Why *not* ERROR: index row size xxxx exceeds maximum 2712 for index "foo"?
We have repeatedly seen failing attempts to index columns with values exceeding a maximum size. Postgres 10 has this kind of error message for it:
ERROR: index row size xxxx exceeds maximum 2712 for index "foo_idx"
HINT: Values larger than 1/3 of…
Erwin Brandstetter
- 146,376
- 19
- 347
- 493
10
votes
3 answers
How to check if I am hitting the Express Edition size limit?
I am confused. AFAIK SQL Server 2005 Express has a limit of 4GB database data size. However I have the following results from sp_spaceused:
How can I check if my DB is hitting the size limit?
Is unallocated space the space left untill I hit the…
g00fy
- 211
- 1
- 2
- 4
7
votes
2 answers
Postgres slow query with order by, index and limit
I am trying to improve the performance of a postgres(9.6) query. Here is my schema and table contains about 60 million rows.
Column | Type |…
Zeeshan
- 71
- 1
- 6
7
votes
3 answers
COUNT(*) gives more than 1 with LIMIT 1?
I'm trying to count old records. Why does Postgres give a result of 1160, even though I set some limit, LIMIT 1 in this case?
SELECT COUNT(*) FROM data WHERE datetime < '2015-09-23 00:00:00' LIMIT 1;
count
--------
1160
(1 row)
I expected a…
happy_marmoset
- 429
- 2
- 6
- 10
6
votes
1 answer
UPDATE Only one row (using update and join)
I'm trying to get a fast, simple sql query to update only one row at a time while using join too.
I have tried LIMIT, but to no success.
Query:
UPDATE
table1
JOIN
table2 ON table2.col=table1.col
SET
table1.row1='a value'
WHERE
table1.row2 LIKE…
Abdelhafidh Belalia
- 61
- 1
- 1
- 3
5
votes
1 answer
Limits of applock in MS SQL Server
Microsoft SQL Server offers an arbitrary application-defined locking mechanism through the sp-getapplock command and related commands.
The key, or resource_name, is specified as a string, a varchar 255. But the documentation also mentions that the…
Basil Bourque
- 8,776
- 14
- 46
- 78
4
votes
2 answers
MySQL LIMIT within JOIN
I have an 1:m association.
symbols table has many rows in company_key_statistics table. company_key_statistics has column createdAt which is timestamp indicating when row has been created.
I need to join latest symbols with company_key_statistics,…
Aren Hovsepyan
- 171
- 1
- 2
- 6
4
votes
1 answer
PostgreSQL Size Quota on Table or Schema
How do one limit the size of a PostgreSQL table? (or schema)
Limit in either bytes or rows would be OK.
I'm starting to think that there's no easy and obvious solution.
I have a lot of identical tables in multiple schemas (my take on multi-tenancy)…
kirilian
- 41
- 2
4
votes
2 answers
ORDER BY indexedColumn ridiculously slow when used with LIMIT on MySQL
The MyISAM table has 4.5m rows. Query with just LIMIT returns fast; query with just ORDER BY returns fast; combining both it never finishes. I've also tried USE INDEX(indexedColumn, Latitude, Longitude), but it doens't help.
SELECT * FROM stuff…
Caleb Pitman
- 207
- 2
- 9
4
votes
1 answer
Query with limit and order by runs too slow
I have the following table:
CREATE TABLE dpg2
(
account_id integer NOT NULL,
tank_id integer NOT NULL,
battles integer,
dmg integer,
frags integer,
wins integer,
recent_battles integer[],
recent_dmg integer[],
recent_frags…
Spencer McLaughlin
- 43
- 1
- 4