Home / Current Issue / Paper 1716727
Prompt Patterns That Improve Text-To-SQL Accuracy Under Increasing Schema Complexity
Subject area: Science,Engineering and Technology · Area of research: Schema Complexity
DOI: 10.64388/IREV8I12-1716727
Abstract
Text-to-SQL systems allow users who are not technical experts to convert natural language queries to runnable SQL queries, although their accuracy tends to decrease with the complexity of the database schema. When using complex schemas (e.g. with many-to-many joins, column names that are ambiguous, multi-table dependencies), the problem of complex schemas is serious and standard prompting strategies may prove ineffective. This paper compares four prompting strategies, such as constraint-based prompts, schema summarisation prompts, few-shot example prompts, and stepwise reasoning prompts, at different levels of schema complexity. Benchmark schemas were built with more and more tables and intra-table connections with each other, and the accuracy of their performance was determined using exact match accuracy, execution accuracy and the join prediction accuracy. Tables and figures demonstrate timely structures, measurement criteria and error distributions based on the level of complexity. Findings have shown that stepwise reasoning and schema summary prompts are more effective than other schema summary strategies with more than 7 tables and multiple many-to-many joins. Prompts based on constraints maintain SQL constraints successfully but are weak in dealing with the ambiguous names of columns, whereas few-shot examples are subject to prompt length and token constraints. According to the error analysis, complex joins and column ambiguity are the primary causes of wrong SQL generation. The findings can be used in practice by developing well-trained prompt patterns in LLM-based Text-to-SQL systems and offer both a systematic and reproducible evaluation platform to research and practice.
Keywords
Text-to-SQL, Large Language Models (LLMs), Prompt Engineering, Schema Complexity, SQL Accuracy, Stepwise Reasoning, Few-Shot Prompting
References
[1] Adanza, D., Gifre, L., Ojaghi, B., Alemany, P., Muñoz, R., & Vilalta, R. (2026). A domain-specific autonomous agent for network traffic analysis. Computer Networks, 274. https://doi.org/10.1016/j.comnet.2025.111809
[2] Attouche, L., Baazizi, M. A., Colazzo, D., Ghelli, G., Sartiani, C., & Scherzinger, S. (2024). Validation of Modern JSON Schema: Formalisation and Complexity. Proceedings of the ACM on Programming Languages, 8. https://doi.org/10.1145/3632891
[3] Chen, B., Zhang, Z., Langrené, N., & Zhu, S. (2025, June 13). Unleashing the potential of prompt engineering for large language models. Patterns. Cell Press. https://doi.org/10.1016/j.patter.2025.101260
[4] Cui, H., Peng, T., Bao, T., Han, R., Han, J., & Liu, L. (2023). Stepwise relation prediction with a dynamic reasoning network for multi-hop knowledge graph question answering. Applied Intelligence, 53(10), 12340–12354. https://doi.org/10.1007/s10489-022-04127-6
[5] Farchaus Stein, K. (1994). Complexity of the self-schema and responses to disconfirming feedback. Cognitive Therapy and Research, 18(2), 161–178. https://doi.org/10.1007/BF02357222
[6] Heston, T. F., & Khun, C. (2023, September 1). Prompt Engineering in Medical Education. International Medical Education. Multidisciplinary Digital Publishing Institute (MDPI). https://doi.org/10.3390/ime2030019
[7] Hong, Z., Yuan, Z., Zhang, Q., Chen, H., Dong, J., Huang, F., & Huang, X. (2025). Next-Generation Database Interfaces: A Survey of LLM-Based Text-to-SQL. IEEE Transactions on Knowledge and Data Engineering. IEEE Computer Society. https://doi.org/10.1109/TKDE.2025.3609486
[8] Huang, D., Gao, J., Luo, X., & Wu, H. (2025). Improving Knowledge Base Question Answering via Retrieval Enhancement and Stepwise Reasoning. In ICASSP, IEEE International Conference on Acoustics, Speech and Signal Processing - Proceedings. Institute of Electrical and Electronics Engineers Inc. https://doi.org/10.1109/ICASSP49660.2025.10890582
[9] Jivani, S., Maheshwari, S., & Sarawagi, S. (2025). Reliable Answers for Recurring Questions: Boosting Text-to-SQL Accuracy with Template Constrained Decoding. Proceedings of the ACM on Management of Data, 3(6), 1–26. https://doi.org/10.1145/3769822
[10] Katsogiannis-Meimarakis, G., & Koutrika, G. (2023). A survey on deep learning approaches for text-to-SQL. VLDB Journal, 32(4), 905–936. https://doi.org/10.1007/s00778-022-00776-8
[11] Knoth, N., Tolzin, A., Janson, A., & Leimeister, J. M. (2024). AI literacy and its implications for prompt engineering strategies. Computers and Education: Artificial Intelligence, 6. https://doi.org/10.1016/j.caeai.2024.100225
[12] Lee, D., & Palmer, E. (2025). Prompt engineering in higher education: a systematic review to help inform curricula. International Journal of Educational Technology in Higher Education, 22(1). https://doi.org/10.1186/s41239-025-00503-7
[13] Liu, X., Shen, S., Li, B., Ma, P., Jiang, R., Zhang, Y., … Luo, Y. (2025). A Survey of Text-to-SQL in the Era of LLMs: Where Are We, and Where Are We Going? IEEE Transactions on Knowledge and Data Engineering, 37(10), 5735–5754. https://doi.org/10.1109/TKDE.2025.3592032
[14] Luoma, K., & Kumar, A. (2025). SNAILS: Schema Naming Assessments for Improved LLM-Based SQL Inference. Proceedings of the ACM on Management of Data, 3(1), 1–26. https://doi.org/10.1145/3709727
[15] Ni, B., Cai, X., Shen, Z., Meng, Z., Zhao, J., Cheng, Y., & Gui, X. (2025). Intelli-Dispatch-SQL: An LLM-based agent for reliable Text-to-SQL in power dispatching. Energy and AI, 22. https://doi.org/10.1016/j.egyai.2025.100591
[16] Oppenlaender, J., Linder, R., & Silvennoinen, J. (2025). Prompting AI Art: An Investigation into the Creative Skill of Prompt Engineering. International Journal of Human-Computer Interaction, 41(16), 10207–10229. https://doi.org/10.1080/10447318.2024.2431761
[17] Painter, J. L., Chalamalasetti, V. R., Kassekert, R., & Bate, A. (2025). Automating pharmacovigilance evidence generation: using large language models to produce context-aware structured query language. JAMIA Open, 8(1). https://doi.org/10.1093/jamiaopen/ooaf003
[18] Pasimeni, F. (2019). SQL query to increase data accuracy and completeness in PATSTAT. World Patent Information, 57, 1–7. https://doi.org/10.1016/j.wpi.2019.02.001
[19] Peng, J., Wang, M., Zhao, X., Zhang, K., Wang, W., Jia, P., … Liu, Q. (2025). Stepwise Reasoning Disruption Attack of LLMs. In Proceedings of the Annual Meeting of the Association for Computational Linguistics (Vol. 1, pp. 5040–5058). Association for Computational Linguistics (ACL). https://doi.org/10.18653/v1/2025.acl-long.251
[20] Pinna, G., Perezhohin, Y., Manzoni, L., Castelli, M., & De Lorenzo, A. (2025). Redefining text-to-SQL metrics by incorporating semantic and structural similarity. Scientific Reports, 15(1). https://doi.org/10.1038/s41598-025-04890-9
[21] Qiu, Y., Wang, Y., Jin, X., & Zhang, K. (2020). Stepwise reasoning for multi-relation question answering over a knowledge graph with weak supervision. In WSDM 2020 - Proceedings of the 13th International Conference on Web Search and Data Mining (pp. 474–482). Association for Computing Machinery, Inc. https://doi.org/10.1145/3336191.3371812
[22] Ramos, J., Rasga, J., & Sernadas, C. (2021). Schema complexity in propositional-based logics. Mathematics, 9(21). https://doi.org/10.3390/math9212671
[23] Rodriguez, L., Lee, S., & Sar, S. (2016). Schema complexity and valence elicited by country logos for tourism. Journal of Visual Literacy, 35(3), 187–200. https://doi.org/10.1080/1051144X.2016.1275341
[24] Saei, S., Ghimire, S., & Anreddy, S. (2026). Beyond Accuracy: Evaluating LLMs for Validating Community Service Provider Directory. In Communications in Computer and Information Science (Vol. 2720 CCIS, pp. 373–380). Springer Science and Business Media Deutschland GmbH. https://doi.org/10.1007/978-3-032-08649-5_23
[25] Sarker, I. H., Janicke, H., Mohsin, A., & Maglaras, L. (2026). SME-TEAM: leveraging trust and ethics for secure and responsible use of AI and LLMs in SMEs. Npj Artificial Intelligence, 2(1). https://doi.org/10.1038/s44387-025-00065-z
[26] Wagner, A., Sprenger, W., Maurer, C., Kuhn, T. E., & Rüppel, U. (2022). Building product ontology: Core ontology for Linked Building Product Data. Automation in Construction, 133. https://doi.org/10.1016/j.autcon.2021.103927
[27] Xinyu, H., Jian, Y., & Gang, X. (2024). Knowledge-injected Stepwise Reasoning on Complex KBQA. In Proceedings of the International Joint Conference on Neural Networks. Institute of Electrical and Electronics Engineers Inc. https://doi.org/10.1109/IJCNN60899.2024.10650658
[28] Yan, L., Wan, Q., Liu, C., Duan, S., Han, P., & Xu, Y. (2025). SPS-SQL: Enhancing Text-to-SQL generation on small-scale LLMs with pre-synthesised queries. Pattern Recognition Letters, 196, 45–51. https://doi.org/10.1016/j.patrec.2025.04.016
[29] Yi, X., Li, Y., Shi, D., Wang, L., Wang, X., & He, L. (2026). Latent-space adversarial training with post-aware calibration for defending large language models against jailbreak attacks. Expert Systems with Applications, 296. https://doi.org/10.1016/j.eswa.2025.129101
[30] Zhong, Z., Yuan, W., Qu, L., Chen, T., Wang, H., Zhao, X., & Yin, H. (2026). Towards On-device Personalisation: Cloud-device Collaborative Data Augmentation for Efficient On-device Language Model. ACM Transactions on Intelligent Systems and Technology, 17(1), 1–22. https://doi.org/10.1145/3779452
How to cite this paper
@article{1716727,
author = {Sai Lalitesh Pothukuchi},
title = {Prompt Patterns That Improve Text-To-SQL Accuracy Under Increasing Schema Complexity},
journal = {Iconic Research And Engineering Journals},
year = {2025},
volume = {8},
number = {12},
pages = {2187-2199},
issn = {2456-8880},
url = {https://www.irejournals.com/formatedpaper/1716727.pdf},
abstract = {Text-to-SQL systems allow users who are not technical experts to convert natural language queries to runnable SQL queries, although their accuracy tends to decrease with the complexity of the database schema. When using complex schemas (e.g. with many-to-many joins, column names that are ambiguous, multi-table dependencies), the problem of complex schemas is serious and standard prompting strategies may prove ineffective. This paper compares four prompting strategies, such as constraint-based prompts, schema summarisation prompts, few-shot example prompts, and stepwise reasoning prompts, at different levels of schema complexity. Benchmark schemas were built with more and more tables and intra-table connections with each other, and the accuracy of their performance was determined using exact match accuracy, execution accuracy and the join prediction accuracy. Tables and figures demonstrate timely structures, measurement criteria and error distributions based on the level of complexity. Findings have shown that stepwise reasoning and schema summary prompts are more effective than other schema summary strategies with more than 7 tables and multiple many-to-many joins. Prompts based on constraints maintain SQL constraints successfully but are weak in dealing with the ambiguous names of columns, whereas few-shot examples are subject to prompt length and token constraints. According to the error analysis, complex joins and column ambiguity are the primary causes of wrong SQL generation. The findings can be used in practice by developing well-trained prompt patterns in LLM-based Text-to-SQL systems and offer both a systematic and reproducible evaluation platform to research and practice.},
keywords = {Text-to-SQL, Large Language Models (LLMs), Prompt Engineering, Schema Complexity, SQL Accuracy, Stepwise Reasoning, Few-Shot Prompting},
month = {June},
doi = {https://doi.org/10.64388/IREV8I12-1716727}
}