1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.

Slides:



Advertisements
Similar presentations
Enhancing Productivity with MySQL 5.6 New Features
Advertisements

1.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Your customer as a segment of one That changes every second! Hein Van Der Merwe Chief.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Debugging Introduction to Computing Science and Programming I.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Track the changes in your Apex application between releases: Yes you can Plsql.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer What’s New in Version 4.1 Jeff Smith
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer For the DBA Jeff Smith
The Safe Harbor The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated.
Chapter 5 Data Manipulation and Transaction Control Oracle 10g: SQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1 Preview of Oracle Database 12 c In-Memory Option Thomas Kyte
QAD .Net UI: New Enhancements
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Application Express 4.1 New Features Hilary Farrell, Principal Member of Technical Staff, Oracle.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Reporting from Contract.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
What is Sure BDCs? BDC stands for Batch Data Communication and is also known as Batch Input. It is a technique for mass input of data into SAP by simulating.
Oracle Application Express 3.0 Joel R. Kallman Software Development Manager.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
RMB Billing UX Design Concepts / Proposals Peter Picone.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Contract Management.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
CS 111 – Nov. 10 Structured Query Language (SQL) –We’ve already seen simple select statements, with optional “where” clause and aggregate functions. –More.
| Building the Effective Enterprise The Power of.Net Upgrade Jeffrey Steele – Solution Consultant, QAD.
SQL Tuning made much easier with SQLTXPLAIN (SQLT) Mauro Pagano Senior Principal Technical Support Engineer Oracle Confidential – Internal/Restricted/Highly.
Page 1 SQL Server Myths XV ENCONTRO DA COMUNIDADE SQLPORT Rui Ribeiro MCITP 2011/08/16.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1.
Oracle Data Integrator Procedures, Advanced Workflows.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Really Cool Demo Stuff – 2015 Edition!!!!! For demo content, please.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Quick Tips for Database Performance Tuning Sergey Koltakov Kurt Engeleiter Product Manager.
Creating PHPs to Insert, Update, and Delete Data CS 320.
A Brief Documentation.  Provides basic information about connection, server, and client.
“This presentation is for informational purposes only and may not be incorporated into a contract or agreement.”
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Using Edition-based redefinition with PL/SQL How to deploy database code changes.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Workforce Scheduling Release 5.0 for Windows Implementation Overview OWS Development Team.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
Oracle Business Intelligence Foundation – Testing and Deploying OBI Repository.
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
5 Copyright © 2008, Oracle. All rights reserved. Testing and Validating a Repository.
2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any.
13 Copyright © 2007, Oracle. All rights reserved. Using the Data Recovery Advisor.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
HOW TO DESKTOP USE by Mario C. Ponciano – a.k.a: Razec DBJMIN MULTI-DB Client (easy-to-use) (Step-by-Step) Jun/ v0.1.
Fundamental of Databases
Table spaces.
Advanced Accounting Information Systems
My Oracle Support (The next generation Metalink experience) lynn
Flight Recorder in OpenJDK
Charles Phillips screen
QAD Reporting Framework
OpenWorld How to Prepare Data from Business Intelligence Cloud Service
OpenWorld 2018 How to Get Value from Data in Oracle Analytics Cloud
Confidential – Oracle Internal/Restricted/Highly Restricted
8 6 MySQL Special Topics A Guide to MySQL.
R11 Product Release Update March 2008
1.
Objectives Define and describe transactions
Presentation transcript:

1

When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle

3 What to do? Find the problem Fix it

4 How? There are several easy methods Today I am going to show them

5 Part 1. Simple cases How to find the cause How to fix it Best practices

6 Incorrect syntax Trivial, but still need to be considered Can fake queries with correct syntax Can be incorrect depending from SQL mode If dynamically created in application can be tricky to find

7 Incorrect syntax select * fro t1 where f1 in (1,2,1); select max (f1) from t1; Correct syntax: max(f1)‏ select * from t1 where "f1"=1; Works with SQL Mode ANSI_QUOTES only

8 Incorrect syntax Always get query in state which MySQL gets it –Use methods of your API to output query (echo, print etc.)‏ –Use MySQL general query log –Use MySQL Proxy to catch the query

9 Logical error Find query results of which are not correct first Try it using MySQL command line client If problem is repeatable analyse why this happens Fix it

10 If query works properly Usually noticeable in applications Go back 1 step, check if you inserted correct data Repeat previous suggestion until you find wrong logic Fix it

11 Cause found, what to do next? Typical cases which cause the problem with description how to fix

12 First try After finding query which causes the problem rewrite it so it works as expected Test if it really works as expected Use EXPLAIN EXTENDED to find query execution plan

13 DML query Convert DML query to SELECT –Examine which queries returns WHERE clause –Use EXPLAIN EXTENDED if needed Fix the query Be sure everything works fine

14 Query rewriting does not help Check MySQL server and client options Start test environment from default values (run mysqld -- no-defaults)‏ If problem is not repeatable anymore Add options like you have in production one-by-one until one which causes the problem found

15 Query rewriting does not help Try to remove indexes from tables affected Try to remove ORDER BY and GROUP BY clauses Try to simplify query as much as possible to see if easier one returns correct results

16 Query rewriting does not help Check if this is known MySQL bug or gotcha Check – – (paying customers only)‏ –These 2 URLs contain partially different bugs content! Apply workaround if exists

17 Problem is not repeatable with single thread Use SHOW PROCESSLIST to find queries running in parallel which block current query Use table INFORMATION_SCHEMA.PROCESSLIST if you need list of simultaneous queries ordered by one of parameters.

18 Problem is not repeatable with single thread Use SHOW ENGINE INNODB STATUS, InnoDB monitors and new INFORMATION_SCHEMA.INNODB_* tables to find information about parallel transactions Use general query log if above do not help Use your application means to find the problem

19 A lot of data Symptoms: –ERROR 1153 (08S01) at line 33: Got a packet bigger than 'max_allowed_packet' bytes –ERROR 1064 (42000) at line 33: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ' at line 2 Check value of max_allowed_packet Be sure it is set for both server and client

20 Timeouts Symptoms: –MySQL server has gone away –Lost connection to MySQL server at... First check error log to be sure this is not a crash Variables: –connect_timeout –interactive_timeout –net_read_timeout, net_write_timeout –wait_timeout

21 Best practices Always use error log Get same query as MySQL server gets it before start debugging Use general query log to find problematic queries Check options Use bug databases and google to find workaround in case of bug/gotcha

22 Best practices Try everything in development environment first –Attend «Sandbox» part of my next session Do backups regularly –Attend «MYSQL ENTERPRISE BACKUP» (364) session at am Use option log_warnings=2 to have information about aborted connections in the error log file

23 Part 2. Complex things Crashes Problems repeatable only in production/high load Sandbox Best practices

24 ?

25 Thank you!

26

27 The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.