Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Database Foundations SQL Calculating, Aggregating and Other Functions String Functions

What benefit has manipulate Strings directly in the query and not in the Programming Language that i'm using for my app?

I was wondering, what option is better?. Languages like Python are more efficient in String manipulation, so, is it necessary manipulate them in the query?, or can i retrieve the data pure, and then edit in my development language?

PS: Sorry for my English, im a Spanish Native Speaker

1 Answer

Casey Ydenberg
Casey Ydenberg
15,622 Points

Remember that the database engine is often on a different server than the app, and that once the query is executed everything retrieved from it will be in memory (instead of stored on disk). So to scale you need to limit and sort your query with the database engine wherever possible. If your query returns millions of records and you plan to sort them in your backend language, it won't work.

(Note that for doing things like inserting a single record it may not matter; mostly this matters for search and sort type queries).