[SOLVED]After Upgrade, my sql command does not work

Moderator: crythias

Post Reply
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

[SOLVED]After Upgrade, my sql command does not work

Post by dtosun »

Hi,

Anybody help me to resolve my problem. After upgrade from 3.2.10 to 3.3.5, my SQL command does not work. What was changed in DB? It was working good in 3.2.10.

My SQL is;

Code: Select all

SELECT (SELECT GROUP_CONCAT(dfv.value_text)
        FROM dynamic_field_value dfv
        WHERE dfv.id = t.id
        ) dynamic_field_values , t.id ticket_id, t.tn ticket_number, t.title ticket_title, t.queue_id, q.name queue_name, t.ticket_lock_id, tl.name ticket_lock_name, t.type_id, tt.name type_name,
				   t.service_id, s.name service_name, t.sla_id, sl.name sla_name, t.user_id, u.login user_name, t.responsible_user_id, u_resp.login responsible_user_name, 
				   t.ticket_priority_id, tp.name ticket_priority_name, t.ticket_state_id, ts.name ticket_state_name, tst.id ticket_state_type_id, tst.name ticket_state_type_name, t.customer_id, t.customer_user_id, t.timeout, t.until_time, t.escalation_time, t.escalation_update_time,t.escalation_response_time, 
				   t.escalation_solution_time, t.valid_id, v.name valid_name, t.archive_flag, t.create_time_unix create_time, t.create_by, ucr.login create_by_name, 
				   t.change_time, t.change_by, uch.login change_by_name,
				   (
					SELECT UNIX_TIMESTAMP(ai.create_time)
					FROM article ai
					INNER JOIN article_type ait ON ait.id = ai.article_type_id
					WHERE ai.ticket_id = t.id
					and ai.article_type_id IN (1,10)
					ORDER BY ai.id
					LIMIT 1
					) first_response_time,
					
					(
					SELECT UNIX_TIMESTAMP(thi.create_time)
					FROM ticket_history thi
					INNER JOIN ticket_state tsi ON tsi.id = thi.state_id
					INNER JOIN ticket_state_type tsti ON tsi.type_id = tsti.id
					WHERE thi.ticket_id = t.id
					AND thi.history_type_id = 27
					AND tsti.id = 3
					ORDER BY thi.id DESC
					LIMIT 1

					 ) close_time
				   
			FROM ticket t
			INNER JOIN queue q on t.queue_id = q.id
			INNER JOIN ticket_lock_type tl on tl.id = t.ticket_lock_id
			INNER JOIN ticket_type tt ON tt.id = t.type_id
			LEFT OUTER JOIN service s ON s.id = t.service_id
			LEFT OUTER JOIN sla sl ON sl.id = t.sla_id
			INNER JOIN users u ON u.id = t.user_id
			INNER JOIN users u_resp ON u_resp.id = t.user_id
			INNER JOIN ticket_priority tp ON tp.id = t.ticket_priority_id
			INNER JOIN ticket_state ts ON ts.id = t.ticket_state_id
			INNER JOIN ticket_state_type tst ON tst.id = ts.type_id
			INNER JOIN valid v ON v.id = t.valid_id
			LEFT OUTER JOIN users uch ON uch.id = t.change_by
			LEFT OUTER JOIN users ucr ON ucr.id = t.create_by
			ORDER BY t.id DESC
Last edited by dtosun on 30 Apr 2014, 14:58, edited 1 time in total.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: After Upgrade, my sql command does not work

Post by jojo »

there were a lot of changes. Check actual ERP diagram or SQL update script. Posting the error would also be good.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

jojo wrote:there were a lot of changes. Check actual ERP diagram or SQL update script. Posting the error would also be good.
Can you share these documents with me. When i run this sql, all tables are locked and OTRS is crashed.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: After Upgrade, my sql command does not work

Post by jojo »

"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

Thank for your support. I need these two info for tickets. How can i get these two info? Any SQL command or function are helpfull for me.

"first_response_time" and "close_time"
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: After Upgrade, my sql command does not work

Post by jojo »

use the statistic type ticket list to get the info
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

jojo wrote:use the statistic type ticket list to get the info
I know, but i should get it via SQL or function, because i will transfer these data to other database to report it. Please help me.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: After Upgrade, my sql command does not work

Post by jojo »

the SQL command you posted ist not for these values. I send you the ERP diagram. You should be able to analyse it and write a new SQL.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: After Upgrade, my sql command does not work

Post by jojo »

also the SQL works like a charm on a 3.3.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

jojo wrote:also the SQL works like a charm on a 3.3.
Sure? Is it working 3.3? When i try there is no response and DB was crashed:(
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: After Upgrade, my sql command does not work

Post by jojo »

well my testsystem has only a few tickets.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

jojo wrote:well my testsystem has only a few tickets.
Ok, our live system has over 20000 tickets. What is wrong i could not understand:(
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: After Upgrade, my sql command does not work

Post by crythias »

If the db is crashed, repair it. Hope you have a backup.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

crythias wrote:If the db is crashed, repair it. Hope you have a backup.
Crash means locked:) My sql is working but my old version takes 3 minutes. But at the moment, it takes 54minutes.
Do you have any suggestion?
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: After Upgrade, my sql command does not work

Post by crythias »

Without understanding why you need to get everything from all your tickets on a consistent basis, the first response is "don't do this" ...
Or: run this intensive command against a replication database in off hours.
Or: Cache this request to a file
Or: EXPLAIN the sql request (keyword term. Ask the server to explain it).

Your query is overbroad and not optimized for your data set.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

crythias wrote:Without understanding why you need to get everything from all your tickets on a consistent basis, the first response is "don't do this" ...
Or: run this intensive command against a replication database in off hours.
Or: Cache this request to a file
Or: EXPLAIN the sql request (keyword term. Ask the server to explain it).

Your query is overbroad and not optimized for your data set.
Because i transfer all data to Oracle BI for reporting. Before upgrade, it was working well:(
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: After Upgrade, my sql command does not work

Post by crythias »

Optimize your query.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
dtosun
Znuny newbie
Posts: 24
Joined: 12 Sep 2012, 14:00
Znuny Version: 4.0.13
Real Name: Dursun Tosun

Re: After Upgrade, my sql command does not work

Post by dtosun »

crythias wrote:Optimize your query.
After optimize my query, it is working well. Thank you for your support.
Post Reply