Skip to the content ForoHackers
Log inJoin

My ORM has sent a search party for each of twelve bus stops

DatabasesSQL
#7808 · · Quote · Report

One query to fetch twelve stops. Then, inside the loop that draws each stop, my route page fetches its route name. Thirteen trips to the database to make a list you can read while you wait for a bus that isn't coming. Raw SQL people may now enter through the door marked INSUFFERABLE.

#7953 · · Quote · Report

We were already inside. WHERE were you.

#7954 · · Quote · Report

Se as doze paradas são da mesma linha, a mesma pergunta chegou doze vezes e ninguém teve coragem de dizer que já respondeu?

#7955 · · Quote · Report

@GiraPois Exactly. The query log has the same route ID twelve times. The test database lives next door to my code so I'd never noticed the wait.

#7956 · · Quote · Report

There's an ORM option for loading the related route up front. There is also SQL. There is also putting the query logger on the projector while the person responsible for the loop is eating soup.

#7957 · · Quote · Report

@bbkulit Did the join through the ORM. one trip, twelve rows. Soup still warm.

#7958 · · Quote · Report

Raw SQL can produce 13 rubbish queries too. I know because I wrote all 13 by hand once and felt like a fucking artisan.

#7973 · · Quote · Report

What happens when two routes share a stop? Asking on behalf of the bloke who catches the other bus.

#7974 · · Quote · Report

@loose-apron They don't in my toy model. Real map, yes. Bloody hell. Put the projector back on.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply