Converting T-SQL code to PL/pgSQL with confidence
Key Takeaways
Converting T-SQL code to PL/pgSQL using Database Migration Service (DMS) and understanding the performance benefits of refactored code, with explanations from Gemini, a trusted AI tutor on Google Cloud.
Full Transcript
You'll find stored procedures like this, complex [music] multi-step processes that rely on temporary tables or cursors to get the job done. They work, but they're often inefficient and don't translate well to modern database patterns. >> [music] >> A basic conversion tool might copy that logic line for line. Functional? Sure, but efficient? Not really. But what if your tool could act as a virtual architect, refactoring your code into better, more performant patterns? [music] Here we have a T-SQL procedure called get high value customers. It creates a temporary table, inserts some initial data, and updates it with more information before selecting the result. It's a classic procedural pattern. Now let's look at the conversion with Database Migration Service or DMS on the right. It hasn't created a temporary table. Instead, [music] it's refactored the entire multi-step process into a single elegant Postgres function using a common table expression or CTE. This isn't just [music] a translation, it's an intelligent modernization. DMS recognized the intent of the code and implemented it using a superior pattern. >> [music] >> But why is this better? Let's ask Gemini. Gemini's explanation is spot on. It tells us that the temporary table was refactored into a CTE [music] to promote a set-based approach, which is the standard way to do it in Postgres. It also dives in on the performance benefits. This allows the Postgres query planner to see the entire operation as a single unit, creating a much more efficient execution plan, and reducing IO compared to writing to and reading from a physical temporary table. DMS just taught us a performance tuning technique. DMS isn't just converting code, it's explaining and guiding you towards modern, maintainable, performant patterns with clear [music] intent and best practices built in. Ready to refactor and modernize your most complex legacy code? Let DMS help you modernize as you migrate. Check out the link in the description below. >> [music]
Original Description
Database Migration Service → https://goo.gle/48NKXTj
Developers migrating apps to the cloud who need to convert database schemas and code to PostgreSQL, or anyone looking to improve PostgreSQL skills, can rely on Gemini as a trusted AI tutor on Google Cloud.
Watch along to learn how to convert T-SQL code into PL/pgSQL, focusing on tricky situations like refactoring a T-SQL procedure into a PostgreSQL Common Table Expression. Gemini doesn't just convert code—it explains how the process works so developers can become PostgreSQL experts too.
Watch more Gemini taught me PostgreSQL → https://goo.gle/ai-postgres-tutor
🔔 Subscribe to Google Cloud Tech → https://goo.gle/GoogleCloudTech
#GoogleCloud #PostgreSQL
Speakers: Gabe Weiss
Products Mentioned: Database Migration Service, Gemini
More on: Database Integration
View skill →Related Reads
📰
📰
📰
📰
Node.js vs Bun vs Deno in 2026: The Ultimate JavaScript Runtime Comparison
Medium · Programming
Node.js vs Bun vs Deno in 2026: The Ultimate JavaScript Runtime Comparison
Medium · JavaScript
Why are Nest.js
Medium · Programming
Node.js Queue Push Webhook Subscriber: Public HTTPS Endpoint Verification
Dev.to · ZebedeeHolloway9023
🎓
Tutor Explanation
DeepCamp AI