Tags
Note
This post is a thought. It's a short note that I make about someone else's content online. Learn more about the process thoughts
Here's my thought on π Read a Range of Data - LIMIT and OFFSET - SQLModel
Today I was running some sqlmodel queries through the sqlalchemy orm. Admittedly I've not done enough orm queries before, and I've done quite a bit of raw sql. I was trying to get objects from two separate models that had relationships setup.
session.query(User, Images).where(User.id == 3).all()
It is incredibly slow, and gives me the following warning.
SELECT statement has a cartesian product between FROM element(s)
What I learned from the SQLModel docs is that you should give it a join to correct this and go much faster.
session.query(User, Images).join(Images).where(User.id == 3).all()
This post was a thought by Waylon Walker see all my thoughts at https://waylonwalker.com/thoughts