0

In postgresql we can get total row count without sending column.

select count(*) from mytable; -- returns count (total number of rows)

Is there any way to so similar thing in sqlalchemy without doing raw query

session.execute('select count(*) from mytable;')
2

1 Answer 1

1

That's a bad idea, because

  • lots of empty rows consume more space than a single one with a bigint

  • such a query does not conform to the SQL standard, so you lose portability for no good reason

Go with

SELECT count(*) FROM mytable;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.