---
title: "Comment by Philipp Salvisberg on \"Query Rewrite - My Story of a Performance Nightmare\" | Hashnode"
description: "Caro, nice write-up. You wrote, \"Due to the complex nature of our queries this took sometimes 30 seconds and more.. :(\". IMO it would be interesting to explore"
url: "https://hashnode.com/posts/query-rewrite-my-story-of-a-performance-nightmare/662e404658beadbf834b8a13/comment/662f534b509598ca67cb1d48"
---

[Discussion](https://hashnode.com/posts/query-rewrite-my-story-of-a-performance-nightmare/662e404658beadbf834b8a13)

Comment [Query Rewrite - My Story of a Performance Nightmare](https://hashnode.com/posts/query-rewrite-my-story-of-a-performance-nightmare/662e404658beadbf834b8a13)

[Philipp Salvisberg](https://hashnode.com/@phsalvisberg)

[Apr 29, 2024](https://hashnode.com/posts/query-rewrite-my-story-of-a-performance-nightmare/662e404658beadbf834b8a13/comment/662f534b509598ca67cb1d48)

Caro, nice write-up. You wrote, "Due to the complex nature of our queries this took sometimes 30 seconds and more.. :(". IMO it would be interesting to explore why parsing took so long. There are several possible reasons for that. In any case, 30 seconds is far too long. It should always be less than a second which probably would have been unnoticed by the users. 30 seconds is also not acceptable for new sessions. Therefore, fixing the parsing issue would have been an adequate solution approach.

[Caro Krützmann](https://hashnode.com/@caroKruetzi)

[Apr 29, 2024](https://hashnode.com/posts/query-rewrite-my-story-of-a-performance-nightmare/662e404658beadbf834b8a13/comment/662f534b509598ca67cb1d48#reply-662fea4c76126818cf3c35ae)

Hi Philipp, thank you very much for your response :) I've added a note for the long parse time. The queries were using many objects via Views on Views on Views with the MViews in between. So we used a lot of objects (can't remember the exact number anymore) and the parse time seemed to be reasonable. At least the Tuning guys didn't mention it specifically :D

What bothers me is the different behavior when selecting data from a query with Query Rewrite and selecting data from the Materialized View directly. I can imagine that the Optimizer is forced to get a new plan due to changes in the data. Maybe it would then decide to query the data directly from the table and not from the Materialized View 🤔
