Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
Wade_Database
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
solho
Wade_Database
Commits
e2e5990d
Commit
e2e5990d
authored
Feb 08, 2022
by
solho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:案件統計 邏輯重構,修改官方發文日取得順序邏輯
parent
b133c2ef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
0 deletions
+102
-0
其他/SQL效能.sql
其他/SQL效能.sql
+102
-0
報表/rpt_CustCaseTot_board_dev.sql
報表/rpt_CustCaseTot_board_dev.sql
+0
-0
報表/rpt_CustCaseTot_board_test -dev.sql
報表/rpt_CustCaseTot_board_test -dev.sql
+0
-0
No files found.
其他/SQL效能.sql
0 → 100644
View file @
e2e5990d
--前N筆消耗最多效能 與法
SELECT
TOP
50
*
,
(
total_worker_time
/
execution_count
)
AS
avgworkertime
FROM
sys
.
dm_exec_query_stats
s
CROSS
APPLY
sys
.
dm_exec_sql_text
(
s
.
sql_handle
)
ORDER
BY
avgworkertime
DESC
Select
count
(
*
)
from
editing_log
a
--
SELECT
top
100
substring
(
text
,
qs
.
statement_start_offset
/
2
,(
CASE
WHEN
qs
.
statement_end_offset
=
-
1
THEN
len
(
convert
(
nvarchar
(
max
),
text
))
*
2
ELSE
qs
.
statement_end_offset
END
-
qs
.
statement_start_offset
)
/
2
)
,
qs
.
plan_generation_num
as
recompiles
,
qs
.
execution_count
as
execution_count
,
qs
.
total_elapsed_time
-
qs
.
total_worker_time
as
total_wait_time
,
qs
.
total_worker_time
as
cpu_time
,
qs
.
total_logical_reads
as
reads
,
qs
.
total_logical_writes
as
writes
,
last_execution_time
FROM
sys
.
dm_exec_query_stats
qs
CROSS
APPLY
sys
.
dm_exec_sql_text
(
qs
.
sql_handle
)
st
LEFT
JOIN
sys
.
dm_exec_requests
r
ON
qs
.
sql_handle
=
r
.
sql_handle
ORDER
BY
5
DESC
SELECT
TOP
50
wait_type
,
waiting_tasks_count
,
(
wait_time_ms
-
signal_wait_time_ms
)
as
resource_wait_time
,
max_wait_time_ms
,
case
when
waiting_tasks_count
=
0
then
0
else
wait_time_ms
/
waiting_tasks_count
end
as
avg_wait_time
FROM
sys
.
dm_os_wait_stats
WHERE
wait_type
NOT
LIKE
'%SLEEP%'
AND
wait_type
NOT
LIKE
'XE%'
AND
wait_type
NOT
IN
(
'PREEMPTIVE_OS_AUTHENTICATIONOPS'
,
'BROKER_TO_FLUSH'
,
'KSOURCE_WAKEUP'
,
'BROKER_TASK_STOP'
,
'FT_IFTS_SCHEDULER_IDLE_WAIT'
,
'DBMIRROR_EVENTS_QUEUE'
,
'SQLTRACE_BUFFER_FLUSH'
,
'CLR_MANUAL_EVENT'
,
'SQLTRACE_BUFFER_FLUSH'
,
'CLR_AUTO_EVENT'
,
'BROKER_EVENTHANDLER'
,
'BAD_PAGE_PROCESS'
,
'BROKER_TRANSMITTER'
,
'CHECKPOINT_QUEUE'
,
'ONDEMAND_TASK_QUEUE'
,
'REQUEST_FOR_DEADLOCK_SEARCH'
,
'LOGMGR_QUEUE'
,
'BROKER_RECEIVE_WAITFOR'
,
'PREEMPTIVE_OS_GETPROCADDRESS'
)
ORDER
BY
wait_time_ms
DESC
DECLARE
@
ts_now
bigint
SELECT
@
ts_now
=
cpu_ticks
/
(
cpu_ticks
/
ms_ticks
)
FROM
sys
.
dm_os_sys_info
;
SELECT
record_id
,
dateadd
(
ms
,
-
1
*
(
@
ts_now
-
[
timestamp
]),
GetDate
())
as
EventTime
,
SQLProcessUtilization
,
SystemIdle
,
100
-
SystemIdle
-
SQLProcessUtilization
as
OtherProcessUtilization
FROM
(
SELECT
record
.
value
(
'(./Record/@id)[1]'
,
'int'
)
as
record_id
,
record
.
value
(
'(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]'
,
'int'
)
as
SystemIdle
,
record
.
value
(
'(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]'
,
'int'
)
as
SQLProcessUtilization
,
TIMESTAMP
FROM
(
SELECT
timestamp
,
CONVERT
(
xml
,
record
)
as
record
FROM
sys
.
dm_os_ring_buffers
WHERE
ring_buffer_type
=
N
'RING_BUFFER_SCHEDULER_MONITOR'
AND
record
LIKE
'%%'
)
as
x
)
as
y
ORDER
BY
record_id
DESC
;
select
c
.
*
,
*
from
esn_Todos
a
left
join
evw_Employee
b
on
a
.
AssignedTo_userid
=
b
.
user_id
inner
join
esn_todos_Settle
c
on
b
.
Emp_DSNum
=
c
.
DSNum
where
a
.
CaseNo
in
(
'SUP220001CN'
,
'SUP220002CN'
)
and
c
.
Settle_Date
in
(
'2022-01-01'
)
and
a
.
Points
>
0
select
*
from
esn_todos_Settle
SELECT
a
.
id
AS
flowid
,
a
.
esn_todos_sn
,
ISNULL
(
a
.
Is_Settlement
,
0
)
AS
Is_Settlement
,
a
.
Description
,
a
.
StepType_id
,
b
.
Step_Value
,
b
.
Step_Text
,
b
.
Map_Class
,
a
.
StepType_id_Previous
AS
StepType_id_Pre
,
c
.
Step_Value
AS
Step_Value_Pre
,
c
.
Step_Text
AS
Step_Text_Pre
,
c
.
Map_Class
AS
Map_Class_Pre
FROM
dbo
.
esn_todos_Flow
AS
a
LEFT
OUTER
JOIN
dbo
.
esn_todos_Flow_StepType
AS
b
ON
a
.
StepType_id
=
b
.
id
LEFT
OUTER
JOIN
dbo
.
esn_todos_Flow_StepType
AS
c
ON
a
.
StepType_id_Previous
=
c
.
id
LEFT
OUTER
JOIN
dbo
.
evw_Employee
AS
d
ON
a
.
assi
=
c
.
id
LEFT
join
esn_todos_Settle
d
on
b
.
Emp_DSNum
=
c
.
DSNum
SELECT
a
.
sn
,
a
.
proc_id
,
a
.
SubSeq
,
a
.
CaseType
,
a
.
CaseType_Name
,
a
.
CaseNo
,
a
.
TaskDescription
,
a
.
StartDate2
,
a
.
StartDate2_c10
,
a
.
LegalDueDate_c10
,
a
.
AttorneyDueDate
,
a
.
AttorneyDueDate_c10
,
a
.
FinishedDate
,
a
.
FinishedDate_c10
,
a
.
AssignedTo_userid
,
a
.
AssignedTo
,
a
.
AssignedTo_Name
,
a
.
Points
,
CASE
WHEN
(
ISNULL
(
points
,
0
)
<>
0
AND
ISNULL
(
PointsType
,
''
)
<>
'MP'
)
AND
ISNULL
(
exchangeRate
,
0
)
=
0
THEN
1
ELSE
ISNULL
(
exchangeRate
,
0
)
END
AS
exchangeRate
,
a
.
Matter
,
a
.
Matter_Name
,
a
.
PatentType
,
a
.
PatentType_Name
,
a
.
ToDosStatus_Name
,
a
.
AssignStatus
,
a
.
AssignStatus_name
,
a
.
Memo
,
a
.
case_id
,
a
.
date_points_settlement
,
a
.
LegalDueDate
,
a
.
ToDosStatus
,
a
.
PointsType
,
a
.
CustDueDate
,
a
.
TaskClass_id
,
b
.
Names
AS
ecNames
,
b
.
FlowKey
AS
ecFlowKey
,
CASE
WHEN
isnull
(
eb
.
bcName
,
''
)
=
''
THEN
'點數'
ELSE
eb
.
bcName
END
AS
bcName
,
FROM
dbo
.
esn_Todos
AS
a
LEFT
OUTER
JOIN
dbo
.
esn_category
AS
b
ON
b
.
ParentId
=
'subtodos'
AND
a
.
TaskClass_id
=
b
.
FlowKey
LEFT
OUTER
JOIN
dbo
.
esn_BaseCode
AS
eb
ON
eb
.
SubID
=
a
.
PointsType
AND
eb
.
ParentID
=
'pointstype'
LEFT
OUTER
JOIN
dbo
.
evw_Employee
AS
d
ON
a
.
AssignedTo_userid
=
d
.
user_id
WHERE
(
a
.
active
=
1
)
報表/rpt_CustCaseTot_board_dev.sql
View file @
e2e5990d
B
B
...
...
報表/rpt_CustCaseTot_board_test -dev.sql
View file @
e2e5990d
B
B
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment