Questions tagged [limit]

Relates to any sort of limit applied to data or resources, e.g. limiting the size or value of a variable, limiting the rate of incoming traffic or CPU usage. [tag:sql-limit] should be used to refer to the LIMIT keyword in SQL.

Relates to any sort of limit applied to data or resources:

  • Limit a size of a database
  • Limit the admissable value of a variable
  • Limit to the rate of incoming traffic
  • Limit to CPU/reqource usage

Also relating to the mathematical notion of limit: the value that a sequence of numbers "approaches" as the sequence progresses.

Use for questions related to LIMIT keyword in SQL.

4370 questions
52
votes
4 answers

Pagination using MySQL LIMIT, OFFSET

I have some code that LIMITs data to display only 4 items per page. The column I'm using has about 20-30 items, so I need to make those spread out across the pages. On the first page, I have: $result = mysqli_query($con,"SELECT * FROM menuitem…
ValleyDigital
  • 1,460
  • 4
  • 21
  • 37
51
votes
4 answers

JPQL limit query

How can I limit in a select query of JPQL named query? I need the limit to be done in the query level itself and not in the java layer!!! I am trying to use @NamedQueries(value = { @NamedQuery(name =…
user3115056
  • 1,266
  • 1
  • 10
  • 25
50
votes
6 answers

What is a maximum number of arguments in a Python function?

It's somewhat common knowledge that Python functions can have a maximum of 256 arguments. What I'm curious to know is if this limit applies to *args and **kwargs when they're unrolled in the following manner: items = [1,2,3,4,5,6] def…
Soviut
  • 88,194
  • 49
  • 192
  • 260
49
votes
8 answers

Difference between INT_MAX and __INT_MAX__ in C

What is the difference between the 2? __INT_MAX__ is defined without adding a library as far as I know and INT_MAX is defined in limits.h but when I include the library INT_MAX gets expanded to __INT_MAX__ either way (or so does VSCode say). Why…
Thanos Kyprianos
  • 1,628
  • 2
  • 7
  • 13
49
votes
5 answers

PHP: Limit foreach() statement?

How can i limit a foreach() statement? Say i only want it to run the first 2 'eaches' or something?
tarnfeld
  • 25,992
  • 41
  • 111
  • 146
49
votes
2 answers

Combine two sql select queries (in postgres) with LIMIT statement

I've got a table and I want a query that returns the last 10 records created plus the record who's id is x. I'm trying to do - SELECT * FROM catalog_productimage ORDER BY date_modified LIMIT 10 UNION SELECT * FROM catalog_productimage WHERE…
Aidan Ewen
  • 13,049
  • 8
  • 63
  • 88
47
votes
1 answer

How to use the LIMIT argument in an SQLite Query with Android

I am trying to use the following query to get the most recent result by date. Cursor cursor = mDb.query(DATABASE_TABLE, new String[] {KEY_DATE, KEY_REPS, KEY_WEIGHT}, null, null, null, null, KEY_DATE + "DESC", ???); I need to use the limit…
easycheese
  • 5,859
  • 10
  • 53
  • 87
47
votes
5 answers

Is there any point using MySQL "LIMIT 1" when querying on indexed/unique field?

For example, I'm querying on a field I know will be unique and is indexed such as a primary key. Hence I know this query will only return 1 row (even without the LIMIT 1) SELECT * FROM tablename WHERE tablename.id=123 LIMIT 1 or only update 1…
swxxii
  • 2,223
  • 2
  • 15
  • 11
47
votes
6 answers

How to limit max width and height to screen size in CSS?

I'm trying to make a php gallery and thats why I need a good Mask, where the pictures later can be shown. I want the Mask not to be bigger than screen-size. I mean, there must be no scrolling and the whole needs to have just the width and…
hans2020dieter
  • 579
  • 1
  • 4
  • 5
47
votes
3 answers

PostgreSQL - repeating rows from LIMIT OFFSET

I noticed some repeating rows in a paginated recordset. When I run this query: SELECT "students".* FROM "students" ORDER BY "students"."status" asc LIMIT 3 OFFSET 0 I get: | id | name | status | | 1 | foo | active | | 12 | alice…
keewooi
  • 952
  • 2
  • 9
  • 10
46
votes
4 answers

What are the current cookie limits in modern browsers?

What are the generic cookie limits for modern browsers, as of 2011? I'm particularly interested in: Max size of a single cookie Max number of cookies per host/domain name + path Max number of cookies per host/domain name Max number / max total size…
GreyCat
  • 16,622
  • 18
  • 74
  • 112
46
votes
4 answers

How can I select rows in MySQL starting at a given row number?

Say I have 50 rows in a MySQL table. I want to select the first ten (LIMIT 10), but then I want to be able to select the next 10 on a different page. So how do I start my selection, after row 10? Updated query: mysql_query(" SELECT * FROM…
mrpatg
  • 10,001
  • 42
  • 110
  • 169
45
votes
4 answers

Extremely slow PostgreSQL query with ORDER and LIMIT clauses

I have a table, let's call it "foos", with almost 6 million records in it. I am running the following query: SELECT "foos".* FROM "foos" INNER JOIN "bars" ON "foos".bar_id = "bars".id WHERE (("bars".baz_id = 13266)) ORDER BY "foos"."id" DESC LIMIT 5…
jakeboxer
  • 3,300
  • 4
  • 26
  • 27
45
votes
6 answers

Limiting results in MongoDB but still getting the full count?

For speed, I'd like to limit a query to 10 results db.collection.find( ... ).limit(10) However, I'd also like to know the total count, so to say "there were 124 but I only have 10". Is there a good efficient way to do this?
Geoff
  • 9,470
  • 13
  • 52
  • 67
45
votes
11 answers

Script runtime execution time limit

My Google Apps Script is iterating through the user's Google Drive files and copying and sometimes moving files to other folders. The script is always stopped after certain minutes with no error message in the log. EDITOR's NOTE: The time limit…