Code Optimisation

357
code optimisation Olivier Deschanels, Senior Consultant

Transcript of Code Optimisation

Page 1: Code Optimisation

code optimisationOlivier Deschanels, Senior Consultant

Page 2: Code Optimisation

optimise your code, you must

Page 3: Code Optimisation

optimise your code, you must

Page 4: Code Optimisation

optimise your code, you must

レスポンスの速度を向上させるために

リクエストの効率を良くするために

トラフィック量を減らすために

コードを簡易にするために

保守を楽にするために

将来に備えるために

Page 5: Code Optimisation

before coding …

Page 6: Code Optimisation

Murphy was an incurable optimist

Page 7: Code Optimisation

1

Murphy was an incurable optimist

Page 8: Code Optimisation

1

Murphy was an incurable optimist

Page 9: Code Optimisation

1

2

Murphy was an incurable optimist

Page 10: Code Optimisation

1

2

Murphy was an incurable optimist

Page 11: Code Optimisation

1

2

3

Murphy was an incurable optimist

Page 12: Code Optimisation

1

2

3

Murphy was an incurable optimist

Page 13: Code Optimisation

1

2

3

4

Murphy was an incurable optimist

Page 14: Code Optimisation

1

2

3

4

Murphy was an incurable optimist

Page 15: Code Optimisation

1

2

3

4

5

Murphy was an incurable optimist

Page 16: Code Optimisation

1

2

3

4

5

Murphy was an incurable optimist

Page 17: Code Optimisation

C/S isn't just a multiprocess standalone

Page 18: Code Optimisation

C/S isn't just a multiprocess standalone

Page 19: Code Optimisation

スタンドアロン版でしかコードを検証していなかった …

C/S isn't just a multiprocess standalone

Page 20: Code Optimisation

スタンドアロン版でしかコードを検証していなかった …

何が起きているのか理解するためにC/S版でデバッグと検証が必要 …

C/S isn't just a multiprocess standalone

Page 21: Code Optimisation

スタンドアロン版でしかコードを検証していなかった …

何が起きているのか理解するためにC/S版でデバッグと検証が必要 …

最初からC/S版で開発していれば時間の節約に

C/S isn't just a multiprocess standalone

Page 22: Code Optimisation

wifi makes delays worse

Page 23: Code Optimisation

wifi makes delays worse

Page 24: Code Optimisation

wifi makes delays worse

Page 25: Code Optimisation

wifi makes delays worse

Page 26: Code Optimisation

x 1.2

wifi makes delays worse

Page 27: Code Optimisation

wifi makes delays worse

Page 28: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

wifi makes delays worse

Page 29: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

wifi makes delays worse

Page 30: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

wifi makes delays worse

Page 31: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

x 7.5

wifi makes delays worse

Page 32: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

x 7.5

Time with 'execute on server' method attribute"サーバー上で実⾏メソッド"属性を有効にした場合

wifi makes delays worse

Page 33: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

wifi makes delays worse

Page 34: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

÷23

÷6

wifi makes delays worse

Page 35: Code Optimisation

0 ms 3,750 ms 7,500 ms 11,250 ms 15,000 ms

÷23

÷6

wifi makes delays worse

Page 36: Code Optimisation

know your code activity, you should

Page 37: Code Optimisation

know your code activity, you should

Page 38: Code Optimisation

know your code activity, you should

1

Page 39: Code Optimisation

know your code activity, you should

1

SET DATABASE PARAMETER(Debug log recording;2+4+8+16)

Page 40: Code Optimisation

know your code activity, you should

1

2

Page 41: Code Optimisation

know your code activity, you should

1

2

3

Page 42: Code Optimisation

know your code activity, you should

1

2

3

SET DATABASE PARAMETER(Debug log recording;0)

Page 43: Code Optimisation

know your code activity, you should

1

2

3

4 logs

Page 44: Code Optimisation

know your code activity, you should

1

2

3

4 logs

5 4DDebugLog_1.txt

Page 45: Code Optimisation

know your code activity, you should

1

2

3

4 logs

5 4DDebugLog_1.txt

Page 46: Code Optimisation

know your code activity, you should

1

2

3

4 logs

5 4DDebugLog_1.txt

Page 47: Code Optimisation

too much info; select you must

Page 48: Code Optimisation

too much info; select you must

1

Page 49: Code Optimisation

too much info; select you must

1

2

Page 50: Code Optimisation

too much info; select you must

1

2

Page 51: Code Optimisation

too much info; select you must

1

2

3

Page 52: Code Optimisation

too much info; select you must

1

2

3

Page 53: Code Optimisation

too much info; select you must

1

2

3

4

Page 54: Code Optimisation

too much info; select you must

SET DATABASE PARAMETER(Log command list;"277") SET DATABASE PARAMETER(Debug log recording;2+4+8+16)

1

2

3

4

Page 55: Code Optimisation

too much info; select you must

SET DATABASE PARAMETER(Log command list;"277") SET DATABASE PARAMETER(Debug log recording;2+4+8+16)SET DATABASE PARAMETER(Log command list;"277;341") SET DATABASE PARAMETER(Debug log recording;2+4+8+16)

1

2

3

4

Page 56: Code Optimisation

too much info; select you must

SET DATABASE PARAMETER(Log command list;"277") SET DATABASE PARAMETER(Debug log recording;2+4+8+16)SET DATABASE PARAMETER(Log command list;"277;341") SET DATABASE PARAMETER(Debug log recording;2+4+8+16)

QUERY (277) および QUERY SELECTION (341)

コマンドを監視

1

2

3

4

Page 57: Code Optimisation

set the flags

Page 58: Code Optimisation

SET DATABASE PARAMETER(Debug log recording; 2 + 4 + 8 + 16)

set the flags

Page 59: Code Optimisation

SET DATABASE PARAMETER(Debug log recording; 2 + 4 + 8 + 16)

2 : 引数も記録(メソッドおよびコマンド)

4 : タブ区切りフォーマット

8 : 遅延書き込みモード

16 : プラグインも対象

set the flags

Page 60: Code Optimisation

know your code activity, you should

Page 61: Code Optimisation

know your code activity, you should

1

Page 62: Code Optimisation

know your code activity, you should

1

SET DATABASE PARAMETER(Log command list;"") SET DATABASE PARAMETER(Debug log recording;4+8+16)

Page 63: Code Optimisation

know your code activity, you should

1

2

Page 64: Code Optimisation

know your code activity, you should

1

2

3

Page 65: Code Optimisation

know your code activity, you should

1

2

3

Page 66: Code Optimisation

know your code activity, you should

1

2

3

4

Page 67: Code Optimisation

know your code activity, you should

1

2

3

4

5

Page 68: Code Optimisation

know your code activity, you should

1

2

3

4

5

6

Page 69: Code Optimisation
Page 70: Code Optimisation
Page 71: Code Optimisation

1

Page 72: Code Optimisation

1

2

Page 73: Code Optimisation

1

2

3

Page 74: Code Optimisation

1

2

3

4

Page 75: Code Optimisation

1

2

3

4

5

Page 76: Code Optimisation

1

2

3

4

5

SET DATABASE PARAMETER(Circular log limitation;10)

Page 77: Code Optimisation

1

2

3

4

5

SET DATABASE PARAMETER(Circular log limitation;10)

10 x 10MB = 最⼤100MB

Page 78: Code Optimisation

reduce the use of variables, you must

Page 79: Code Optimisation

variable and variables table

Page 80: Code Optimisation

1

variable and variables table

Page 81: Code Optimisation

1

2

variable and variables table

Page 82: Code Optimisation

1

2

3

variable and variables table

Page 83: Code Optimisation

1

2

3

4

variable and variables table

Page 84: Code Optimisation

1

2

3

4

5

variable and variables table

Page 85: Code Optimisation

1

2

3

4

5

6

variable and variables table

Page 86: Code Optimisation
Page 87: Code Optimisation

サーバー

クライアント#1

クライアント#2

Page 88: Code Optimisation

P1PR1

グローバルプロセス裏⽅のツインプロセス

ネットワーク接続

このプロセスが実⾏ : - トリガ - "サーバー上で実⾏"

Page 89: Code Optimisation

P1

P2

PR1

PR2

Page 90: Code Optimisation

P1

P2

$P3

PR1

PR2

$ローカルプロセス

Page 91: Code Optimisation

P1

P2

$P3

PR1

PR2

P1'

$P2'

PR1'

Page 92: Code Optimisation

P1

P2

$P3

PR1

PR2

P1'

$P2'

PR1'

SP2

SP1

ストアドプロシージャー

Page 93: Code Optimisation

P1

P2

$P3

PR1

PR2

P1'

$P2'

PR1'

SP2

SP1

WP2

WP3

WP1

Webプロセス

Page 94: Code Optimisation

P1

P2

$P3

PR1

PR2

P1'

$P2'

PR1'

SP2

SP1

WP2

WP3

WP1

コンパイル

モード

Page 95: Code Optimisation

P1

P2

$P3

PR1

PR2

<>

P1'

$P2'

PR1'

SP2

SP1

WP2

WP3

WP1

インタープロセス変数テーブル

コンパイル

モード

Page 96: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

SP2

SP1

WP2

WP3

WP1

コンパイル

モード

Page 97: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

SP2

SP1

WP2

WP3

WP1

プロセス変数テーブル

コンパイル

モード

Page 98: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2

SP1

WP2

WP3

WP1

コンパイル

モード

Page 99: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

コンパイル

モード

Page 100: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

コンパイル

モード

Page 101: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

V

V

コンパイル

モード

Page 102: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

V

V

<>CV

<>CV

コンポーネント#1の インタープロセス変数テーブル

コンポーネント#2の インタープロセス変数テーブル

コンパイル

モード

Page 103: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

V

V

<>CV

<>CV

<>CV

<>CV

<>CV

<>CV

コンパイル

モード

Page 104: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

V

V

CVCV

<>CV

<>CV

<>CV

<>CV

<>CV

<>CV

コンポーネント#1の プロセス変数テーブル

コンポーネント#2の プロセス変数テーブル

コンパイル

モード

Page 105: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

V

V

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CV CV

CV CV

CV CV

<>CV

<>CV

<>CV

<>CV

<>CV

<>CV

コンパイル

モード

Page 106: Code Optimisation

P1

P2

$P3

PR1

PR2

<> <>

P1'

$P2'

<>PR1'

V

V

V

V

V

SP2 V

SP1 V

WP2 V

WP3 V

WP1 V

V

V

V

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CVCV

CV CV

CV CV

CV CV

<>CV

<>CV

<>CV

<>CV

<>CV

<>CV

コンパイル

モード

プロセス変数テーブルのサイズに無頓着であってはいけない

Page 107: Code Optimisation

control the size of process variables table

Page 108: Code Optimisation

1

control the size of process variables table

Page 109: Code Optimisation

1

control the size of process variables table

Page 110: Code Optimisation

1

2

control the size of process variables table

Page 111: Code Optimisation

1

2

control the size of process variables table

Page 112: Code Optimisation

1

2

3

control the size of process variables table

Page 113: Code Optimisation

1

2

3

control the size of process variables table

Page 114: Code Optimisation

1

2

3

4

control the size of process variables table

Page 115: Code Optimisation

1

2

3

4

control the size of process variables table

Page 116: Code Optimisation

1

2

3

4

5

control the size of process variables table

Page 117: Code Optimisation

decrease the size of process variables table

Page 118: Code Optimisation

decrease the size of process variables table

1

Page 119: Code Optimisation

decrease the size of process variables table

1

Page 120: Code Optimisation

decrease the size of process variables table

1

Page 121: Code Optimisation

decrease the size of process variables table

1

Page 122: Code Optimisation

decrease the size of process variables table

1

2

Page 123: Code Optimisation

bOk bValid

bValidate b_Ok

buttonOK

decrease the size of process variables table

1

2

Page 124: Code Optimisation

decrease the size of process variables table

1

2

Page 125: Code Optimisation

decrease the size of process variables table

1

2

3

Page 126: Code Optimisation

decrease the size of process variables table

1

2

3

Page 127: Code Optimisation

decrease the size of process variables table

1

2

3

Page 128: Code Optimisation

decrease the size of process variables table

1

2

3

Page 129: Code Optimisation

decrease the size of process variables table

1

2

3

Page 130: Code Optimisation

decrease the size of process variables table

1

2

3

4

Page 131: Code Optimisation

decrease the size of process variables table

1

2

3

4

Page 132: Code Optimisation

decrease the size of process variables table

1

2

3

4

Page 133: Code Optimisation

decrease the size of process variables table

1

2

3

4

Page 134: Code Optimisation

use dynamic variables

Page 135: Code Optimisation

1

use dynamic variables

Page 136: Code Optimisation

1

2

use dynamic variables

Page 137: Code Optimisation

1

2

3

use dynamic variables

Page 138: Code Optimisation

1

2

3

use dynamic variables

Page 139: Code Optimisation

1

2

3

use dynamic variables

Page 140: Code Optimisation

1

2

3

use dynamic variables

Page 141: Code Optimisation

1

2

3

use dynamic variables

Page 142: Code Optimisation

don't push your luck

Page 143: Code Optimisation

don't push your luck

Page 144: Code Optimisation

don't push your luck

Page 145: Code Optimisation

don't push your luck

Page 146: Code Optimisation

プロセス変数を使っても⼤丈夫です!

don't push your luck

Page 147: Code Optimisation

プロセス変数を使っても⼤丈夫です!

ほんとう? それを聴いて安⼼した

don't push your luck

Page 148: Code Optimisation

プロセス変数を使っても⼤丈夫です!"最先端"であるためにコードを複雑にする必要はありません変数のサイズに気を配るのは⼤事ですが,極端に⾛らないで

don't push your luck

Page 149: Code Optimisation

プロセス変数を使っても⼤丈夫です!"最先端"であるためにコードを複雑にする必要はありません変数のサイズに気を配るのは⼤事ですが,極端に⾛らないで

それに今ならオブジェクト変数が…

don't push your luck

Page 150: Code Optimisation

group the variables in an object, you can

Page 151: Code Optimisation

無数のフォームローカル変数を オブジェクト型のプロセス変数に置換:

group the variables in an object, you can

Page 152: Code Optimisation

無数のフォームローカル変数を オブジェクト型のプロセス変数に置換:

{"onTimerMessage":"refresh", "PreviousFormEvent":27, "LastKeystroke":"C", "OnErrorMethodToRestore":"General_Error_Call", "OnEventMethodToRestore":"", "CountryCustomer":"FR", "CurrentQuoteUUID":"EF455411221114778AB3ED45DD", "ListOfCountryInWishList":["US","FR","UK","SA","AU"] }

group the variables in an object, you can

Page 153: Code Optimisation

無数のフォームローカル変数を オブジェクト型のプロセス変数に置換:

{"onTimerMessage":"refresh", "PreviousFormEvent":27, "LastKeystroke":"C", "OnErrorMethodToRestore":"General_Error_Call", "OnEventMethodToRestore":"", "CountryCustomer":"FR", "CurrentQuoteUUID":"EF455411221114778AB3ED45DD", "ListOfCountryInWishList":["US","FR","UK","SA","AU"] }

1個のプロセス変数に保存: form_context

group the variables in an object, you can

Page 154: Code Optimisation

無数のフォームローカル変数を オブジェクト型のプロセス変数に置換:

{"onTimerMessage":"refresh", "PreviousFormEvent":27, "LastKeystroke":"C", "OnErrorMethodToRestore":"General_Error_Call", "OnEventMethodToRestore":"", "CountryCustomer":"FR", "CurrentQuoteUUID":"EF455411221114778AB3ED45DD", "ListOfCountryInWishList":["US","FR","UK","SA","AU"] }

1個のプロセス変数に保存: form_context

プロセス変数テーブルに 16バイト追加することに

group the variables in an object, you can

Page 155: Code Optimisation

無数のフォームローカル変数を オブジェクト型のプロセス変数に置換:

{"onTimerMessage":"refresh", "PreviousFormEvent":27, "LastKeystroke":"C", "OnErrorMethodToRestore":"General_Error_Call", "OnEventMethodToRestore":"", "CountryCustomer":"FR", "CurrentQuoteUUID":"EF455411221114778AB3ED45DD", "ListOfCountryInWishList":["US","FR","UK","SA","AU"] }

1個のプロセス変数に保存: form_context

プロセス変数テーブルに 16バイト追加することに

わずか16バイトで整理できて⼤変お買い得!

group the variables in an object, you can

Page 156: Code Optimisation

無数のフォームローカル変数を オブジェクト型のプロセス変数に置換:

{"onTimerMessage":"refresh", "PreviousFormEvent":27, "LastKeystroke":"C", "OnErrorMethodToRestore":"General_Error_Call", "OnEventMethodToRestore":"", "CountryCustomer":"FR", "CurrentQuoteUUID":"EF455411221114778AB3ED45DD", "ListOfCountryInWishList":["US","FR","UK","SA","AU"] }

1個のプロセス変数に保存: form_context

プロセス変数テーブルに 16バイト追加することに

わずか16バイトで整理できて⼤変お買い得!

属性を追加するだけ拡張: フォームに オブジェクトを追加する必要なし

group the variables in an object, you can

Page 157: Code Optimisation

example with a form_context

Page 158: Code Optimisation

OB SET(form_context;"currentCountry";"France")

$ref:=Open form window("country_selector") DIALOG("country_selector") CLOSE WINDOW($ref )

$return_country:=OB Get(form_context;"currentCountry")

example with a form_context

Page 159: Code Optimisation

OB SET(form_context;"currentCountry";"France")

$ref:=Open form window("country_selector") DIALOG("country_selector") CLOSE WINDOW($ref )

$return_country:=OB Get(form_context;"currentCountry")

example with a form_context

Page 160: Code Optimisation

OB SET(form_context;"currentCountry";"France")

$ref:=Open form window("country_selector") DIALOG("country_selector") CLOSE WINDOW($ref )

$return_country:=OB Get(form_context;"currentCountry")

$evt:=Form event Case of : ($evt=On Load) $currentCountry:=OB Get(form_context;"currentCountry") ALL RECORDS([Country]) DISTINCT VALUES([Country]Continent;_continent) If ($currentCountry="") _continent:=1 OB SET(form_context;"onTimerMessage";"changeContinent") SET TIMER(-1) Else QUERY([Country];[Country]Name=$currentCountry) _continent:=Find in array(_continent;[Country]Continent) QUERY([Country];[Country]Continent=_continent{_continent}) DISTINCT VALUES([Country]Name;_country) _country:=Find in array(_country;$currentCountry) End if

: ($evt=On Timer) SET TIMER(0) $onTimerMessage:=OB Get(form_context;"onTimerMessage";Is text) OB REMOVE(form_context;"onTimerMessage") Case of : ($onTimerMessage="changeContinent") QUERY([Country];[Country]Continent=_continent{_continent}) DISTINCT VALUES([Country]Name;_country) _country:=1 End case End case

example with a form_context

Page 161: Code Optimisation

OB SET(form_context;"currentCountry";"France")

$ref:=Open form window("country_selector") DIALOG("country_selector") CLOSE WINDOW($ref )

$return_country:=OB Get(form_context;"currentCountry")

$evt:=Form event Case of : ($evt=On Load) $currentCountry:=OB Get(form_context;"currentCountry") ALL RECORDS([Country]) DISTINCT VALUES([Country]Continent;_continent) If ($currentCountry="") _continent:=1 OB SET(form_context;"onTimerMessage";"changeContinent") SET TIMER(-1) Else QUERY([Country];[Country]Name=$currentCountry) _continent:=Find in array(_continent;[Country]Continent) QUERY([Country];[Country]Continent=_continent{_continent}) DISTINCT VALUES([Country]Name;_country) _country:=Find in array(_country;$currentCountry) End if

: ($evt=On Timer) SET TIMER(0) $onTimerMessage:=OB Get(form_context;"onTimerMessage";Is text) OB REMOVE(form_context;"onTimerMessage") Case of : ($onTimerMessage="changeContinent") QUERY([Country];[Country]Continent=_continent{_continent}) DISTINCT VALUES([Country]Name;_country) _country:=1 End case End case

OB SET(form_context;"onTimerMessage";"changeContinent") SET TIMER(-1)

example with a form_context

Page 162: Code Optimisation

OB SET(form_context;"currentCountry";"France")

$ref:=Open form window("country_selector") DIALOG("country_selector") CLOSE WINDOW($ref )

$return_country:=OB Get(form_context;"currentCountry")

$evt:=Form event Case of : ($evt=On Load) $currentCountry:=OB Get(form_context;"currentCountry") ALL RECORDS([Country]) DISTINCT VALUES([Country]Continent;_continent) If ($currentCountry="") _continent:=1 OB SET(form_context;"onTimerMessage";"changeContinent") SET TIMER(-1) Else QUERY([Country];[Country]Name=$currentCountry) _continent:=Find in array(_continent;[Country]Continent) QUERY([Country];[Country]Continent=_continent{_continent}) DISTINCT VALUES([Country]Name;_country) _country:=Find in array(_country;$currentCountry) End if

: ($evt=On Timer) SET TIMER(0) $onTimerMessage:=OB Get(form_context;"onTimerMessage";Is text) OB REMOVE(form_context;"onTimerMessage") Case of : ($onTimerMessage="changeContinent") QUERY([Country];[Country]Continent=_continent{_continent}) DISTINCT VALUES([Country]Name;_country) _country:=1 End case End case

OB SET(form_context;"onTimerMessage";"changeContinent") SET TIMER(-1)

OB SET(form_context;"currentCountry";_country{_country}) ACCEPT

example with a form_context

Page 163: Code Optimisation

lighter is faster!

Page 164: Code Optimisation

don't use every possible fields

Page 165: Code Optimisation

don't use every possible fields

Page 166: Code Optimisation

こんにちは。150フィールドの者です。

don't use every possible fields

Page 167: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

don't use every possible fields

Page 168: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

don't use every possible fields

Page 169: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

don't use every possible fields

Page 170: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから

don't use every possible fields

Page 171: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

don't use every possible fields

Page 172: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

備えあれば憂いなし,ってね!

don't use every possible fields

Page 173: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

備えあれば憂いなし,ってね!

コスト的にはどうなの?

don't use every possible fields

Page 174: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

備えあれば憂いなし,ってね!

コスト的にはどうなの?

未使⽤フィールドは空だからタダですよ

don't use every possible fields

Page 175: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

備えあれば憂いなし,ってね!

コスト的にはどうなの?

未使⽤フィールドは空だからタダですよ

don't use every possible fields

Page 176: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

備えあれば憂いなし,ってね!

コスト的にはどうなの?

未使⽤フィールドは空だからタダですよ

don't use every possible fields

Page 177: Code Optimisation

こんにちは。150フィールドの者です。はじめまして!

いろんなケースに対応できるんですよ

ほんとうに?

もちろん! 想定シナリオを100%網羅していますから でも,⼤概は普通のケースですよね?

備えあれば憂いなし,ってね!

コスト的にはどうなの?

未使⽤フィールドは空だからタダですよ

don't use every possible fields

Page 178: Code Optimisation

empty isn't free

Page 179: Code Optimisation

150フィールドのテーブルempty isn't free

Page 180: Code Optimisation

レコードのサイズ 150フィールドのテーブル

ヘッダー 32 バイト 32 バイト

データ 実際のサイズ 実際のサイズ

µストラクチャ 8 バイト×フィールド数 1,200 バイト

合計 最低 1.2 Kb レコード毎

150フィールドのテーブルempty isn't free

Page 181: Code Optimisation

レコードのサイズ 150フィールドのテーブル

ヘッダー 32 バイト 32 バイト

データ 実際のサイズ 実際のサイズ

µストラクチャ 8 バイト×フィールド数 1,200 バイト

合計 最低 1.2 Kb レコード毎

150フィールドのテーブルempty isn't free

Page 182: Code Optimisation

try to keep stable field sizes

Page 183: Code Optimisation

try to keep stable field sizes

Page 184: Code Optimisation

try to keep stable field sizes

Page 185: Code Optimisation

a

try to keep stable field sizes

Page 186: Code Optimisation

a

b

try to keep stable field sizes

Page 187: Code Optimisation

a

b

c

try to keep stable field sizes

Page 188: Code Optimisation

a

b

c

d

try to keep stable field sizes

Page 189: Code Optimisation

a

b

c

d

e

try to keep stable field sizes

Page 190: Code Optimisation

a

b

c

d

e

f

try to keep stable field sizes

Page 191: Code Optimisation
Page 192: Code Optimisation
Page 193: Code Optimisation
Page 194: Code Optimisation

a

Page 195: Code Optimisation

a

b

Page 196: Code Optimisation

a

b

c

Page 197: Code Optimisation

a

b

c

d

Page 198: Code Optimisation

a

b

c

d

e

Page 199: Code Optimisation

a

b

c

d

e

f

Page 200: Code Optimisation

a

b

c

d

e

f

g

Page 201: Code Optimisation

a

b

c

d

e

f

g

h

Page 202: Code Optimisation

"all you can store" syndrome

Page 203: Code Optimisation

"all you can store" syndrome

Page 204: Code Optimisation

"all you can store" syndrome

Page 205: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 206: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 207: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 208: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 209: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 210: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 211: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 212: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 213: Code Optimisation

"all you can store" syndrome

# フィールド

9 Phone1

10 Phone2

11 Fax

35 Phone3

90 Portable

105 email

120 email2

Page 214: Code Optimisation

you must unlearn what you have learned

Page 215: Code Optimisation

you must unlearn what you have learned

Page 216: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

you must unlearn what you have learned

Page 217: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

you must unlearn what you have learned

Page 218: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

you must unlearn what you have learned

Page 219: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

すべてのリレーションを変更する 1個のリレーションだけを変更する

you must unlearn what you have learned

Page 220: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

すべてのリレーションを変更する 1個のリレーションだけを変更する

True, False Do not modify, Structure config., Manual, Automatic

you must unlearn what you have learned

Page 221: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

すべてのリレーションを変更する 1個のリレーションだけを変更する

True, False Do not modify, Structure config., Manual, Automatic

ストラクチャー定義の⾃動リレーションは変更できない ストラクチャー定義の⾃動リレーションも変更できる

you must unlearn what you have learned

Page 222: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

すべてのリレーションを変更する 1個のリレーションだけを変更する

True, False Do not modify, Structure config., Manual, Automatic

ストラクチャー定義の⾃動リレーションは変更できない ストラクチャー定義の⾃動リレーションも変更できる

"True" はリレーションをロックする;その場合 SET FIELD RELATION

は無視されてしまう副作⽤なし

you must unlearn what you have learned

Page 223: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

すべてのリレーションを変更する 1個のリレーションだけを変更する

True, False Do not modify, Structure config., Manual, Automatic

ストラクチャー定義の⾃動リレーションは変更できない ストラクチャー定義の⾃動リレーションも変更できる

"True" はリレーションをロックする;その場合 SET FIELD RELATION

は無視されてしまう副作⽤なし

!

you must unlearn what you have learned

Page 224: Code Optimisation

SET AUTOMATIC RELATIONS SET FIELD RELATION

カレントプロセス内で有効

すべてのリレーションを変更する 1個のリレーションだけを変更する

True, False Do not modify, Structure config., Manual, Automatic

ストラクチャー定義の⾃動リレーションは変更できない ストラクチャー定義の⾃動リレーションも変更できる

"True" はリレーションをロックする;その場合 SET FIELD RELATION

は無視されてしまう副作⽤なし

!

互換性のために残されている 効率⾯で優れている

you must unlearn what you have learned

Page 225: Code Optimisation

you must unlearn what you have learned

Page 226: Code Optimisation

QUERY BY FORMULA QUERY BY FORMULAQUERY SELECTION BY FORMULA

you must unlearn what you have learned

Page 227: Code Optimisation

QUERY BY FORMULA QUERY BY FORMULA

インデックスを使⽤しないシーケンシャル検索 インデックス検索

QUERY SELECTION BY FORMULA

you must unlearn what you have learned

Page 228: Code Optimisation

QUERY BY FORMULA QUERY BY FORMULA

インデックスを使⽤しないシーケンシャル検索 インデックス検索

サーバー側でフォーミュラを評価クライアント側でフォーミュラ式を評価

QUERY SELECTION BY FORMULA

you must unlearn what you have learned

Page 229: Code Optimisation

QUERY BY FORMULA QUERY BY FORMULA

インデックスを使⽤しないシーケンシャル検索 インデックス検索

サーバー側でフォーミュラを評価

⾃動的にJOINを実⾏

クライアント側でフォーミュラ式を評価

レコード1件ずつクライアントに転送

JOINを定義して使⽤

QUERY SELECTION BY FORMULA

you must unlearn what you have learned

Page 230: Code Optimisation

QUERY BY FORMULA QUERY BY FORMULA

インデックスを使⽤しないシーケンシャル検索 インデックス検索

サーバー側でフォーミュラを評価

⾃動的にJOINを実⾏

クライアント側でフォーミュラ式を評価

レコード1件ずつクライアントに転送

JOINを定義して使⽤

以前のアドバイス : 利⽤は慎重に,できる限りQUERY

SELECTIONで対応

現在のアドバイス : v11の主要強化ポイントのひとつ

積極的に使⽤するべき!

QUERY SELECTION BY FORMULA

you must unlearn what you have learned

Page 231: Code Optimisation

you must unlearn what you have learned

Page 232: Code Optimisation

EXECUTE ON CLIENT EXECUTE ON CLIENTREGISTER CLIENT(name;period) REGISTER CLIENT(name)

you must unlearn what you have learned

Page 233: Code Optimisation

EXECUTE ON CLIENT EXECUTE ON CLIENTREGISTER CLIENT(name;period) REGISTER CLIENT(name)

登録後,クライアントは定期的に,デフォルトでは2秒毎に,サーバー あるいは別のクライアントから

呼び出されているか問い合わせる

サーバーは必要なときに実⾏リクエストを直接クライアントに送信する

you must unlearn what you have learned

Page 234: Code Optimisation

EXECUTE ON CLIENT EXECUTE ON CLIENTREGISTER CLIENT(name;period) REGISTER CLIENT(name)

登録後,クライアントは定期的に,デフォルトでは2秒毎に,サーバー あるいは別のクライアントから

呼び出されているか問い合わせる

サーバーは必要なときに実⾏リクエストを直接クライアントに送信する

PULLモード PUSHモード

you must unlearn what you have learned

Page 235: Code Optimisation

EXECUTE ON CLIENT EXECUTE ON CLIENTREGISTER CLIENT(name;period) REGISTER CLIENT(name)

登録後,クライアントは定期的に,デフォルトでは2秒毎に,サーバー あるいは別のクライアントから

呼び出されているか問い合わせる

サーバーは必要なときに実⾏リクエストを直接クライアントに送信する

PULLモード PUSHモード

⼤量リクエストの可能性 必要最低限のリクエスト数

you must unlearn what you have learned

Page 236: Code Optimisation

you must unlearn what you have learned

Page 237: Code Optimisation

TRIGGER TRIGGER

you must unlearn what you have learned

Page 238: Code Optimisation

TRIGGER TRIGGER

トリガはアトミックな操作: トリガが実⾏されている間,

サーバー側のコードがすべて待機トリガは実⾏中のコードを停⽌しない

you must unlearn what you have learned

Page 239: Code Optimisation

TRIGGER TRIGGER

トリガはアトミックな操作: トリガが実⾏されている間,

サーバー側のコードがすべて待機トリガは実⾏中のコードを停⽌しない

コマンドではなく関数

you must unlearn what you have learned

Page 240: Code Optimisation

TRIGGER TRIGGER

トリガはアトミックな操作: トリガが実⾏されている間,

サーバー側のコードがすべて待機トリガは実⾏中のコードを停⽌しない

コマンドではなく関数 C_LONGINT($0) $0:=0

you must unlearn what you have learned

Page 241: Code Optimisation

TRIGGER TRIGGER

トリガはアトミックな操作: トリガが実⾏されている間,

サーバー側のコードがすべて待機トリガは実⾏中のコードを停⽌しない

コマンドではなく関数 C_LONGINT($0) $0:=0

トリガコードでトランザクションを使⽤しない! エラーコード($0) を活⽤する

you must unlearn what you have learned

Page 242: Code Optimisation

at the end, house of cards falls

Page 243: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

end if

at the end, house of cards falls

Page 244: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

end if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

at the end, house of cards falls

Page 245: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

end if

$reference:=[Customer]Reference

$recNum:=Find in field([Customer]Reference;$reference)

If ($recNum>=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

at the end, house of cards falls

Page 246: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

end if

$reference:=[Customer]Reference

$recNum:=Find in field([Customer]Reference;$reference)

If ($recNum>=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

Find in field でバッチリ解決!

at the end, house of cards falls

Page 247: Code Optimisation

at the end, house of cards falls

Page 248: Code Optimisation

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdayPUSH RECORD([Customer])

QUERY([Customer];[Customer]firstName=$firstName;*)QUERY([Customer];[Customer]lastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

End if

at the end, house of cards falls

Page 249: Code Optimisation

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdayPUSH RECORD([Customer])

QUERY([Customer];[Customer]firstName=$firstName;*)QUERY([Customer];[Customer]lastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

at the end, house of cards falls

Page 250: Code Optimisation

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdayPUSH RECORD([Customer])

QUERY([Customer];[Customer]firstName=$firstName;*)QUERY([Customer];[Customer]lastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

End if

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]Birthday

SET QUERY DESTINATION(Into variable;$nb)QUERY([Customer];[Customer]FirstName=$firstName;*)QUERY([Customer];[Customer]LastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)SET QUERY DESTINATION(Into current selection)

If ($nb=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

at the end, house of cards falls

Page 251: Code Optimisation

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdayPUSH RECORD([Customer])

QUERY([Customer];[Customer]firstName=$firstName;*)QUERY([Customer];[Customer]lastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

End if

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]Birthday

SET QUERY DESTINATION(Into variable;$nb)QUERY([Customer];[Customer]FirstName=$firstName;*)QUERY([Customer];[Customer]LastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)SET QUERY DESTINATION(Into current selection)

If ($nb=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

SET QUERY DESTINATION カレントセレクション・レコードを変更せずにクエリを実⾏

at the end, house of cards falls

Page 252: Code Optimisation

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdayPUSH RECORD([Customer])

QUERY([Customer];[Customer]firstName=$firstName;*)QUERY([Customer];[Customer]lastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

End if

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]Birthday

SET QUERY DESTINATION(Into variable;$nb)QUERY([Customer];[Customer]FirstName=$firstName;*)QUERY([Customer];[Customer]LastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)SET QUERY DESTINATION(Into current selection)

If ($nb=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdaySET QUERY LIMIT(1)SET QUERY DESTINATION(Into variable;$nb)QUERY([Customer];[Customer]FirstName=$firstName;*)QUERY([Customer];[Customer]LastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)SET QUERY DESTINATION(Into current selection)SET QUERY LIMIT(0)If ($nb=0)

//do somethingEnd if

SET QUERY DESTINATION カレントセレクション・レコードを変更せずにクエリを実⾏

at the end, house of cards falls

Page 253: Code Optimisation

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdayPUSH RECORD([Customer])

QUERY([Customer];[Customer]firstName=$firstName;*)QUERY([Customer];[Customer]lastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)$nb:=Records in selection([Customer])

POP RECORD([Customer])

If ($nb=0)//do something

End if

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]Birthday

SET QUERY DESTINATION(Into variable;$nb)QUERY([Customer];[Customer]FirstName=$firstName;*)QUERY([Customer];[Customer]LastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)SET QUERY DESTINATION(Into current selection)

If ($nb=0)//do something

End if

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

$firstName:=[Customer]FirstName$lastName:=[Customer]LastName$birthday:=[Customer]BirthdaySET QUERY LIMIT(1)SET QUERY DESTINATION(Into variable;$nb)QUERY([Customer];[Customer]FirstName=$firstName;*)QUERY([Customer];[Customer]LastName=$lastName;*)QUERY([Customer];[Customer]Birthday=$birthday)SET QUERY DESTINATION(Into current selection)SET QUERY LIMIT(0)If ($nb=0)

//do somethingEnd if

SET QUERY LIMIT 0 でリミットを解除

SET QUERY DESTINATION カレントセレクション・レコードを変更せずにクエリを実⾏

at the end, house of cards falls

Page 254: Code Optimisation

at the end, house of cards falls

Page 255: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$firstName:=[Customer]FirstName$lastName:=[Customer]LastName

POP RECORD([Customer])

//do something with $firstName, $lastName ...

at the end, house of cards falls

Page 256: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$firstName:=[Customer]FirstName$lastName:=[Customer]LastName

POP RECORD([Customer])

//do something with $firstName, $lastName ...

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

at the end, house of cards falls

Page 257: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$firstName:=[Customer]FirstName$lastName:=[Customer]LastName

POP RECORD([Customer])

//do something with $firstName, $lastName ...

$reference:=[Customer]Reference$firstName:=""$lastName:=""

Begin SQLselect FirstName, LastName from Customerwhere Reference=:$referenceinto :$firstName, :$lastName

End SQL

//do something with $firstName, $lastName ...

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

at the end, house of cards falls

Page 258: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$firstName:=[Customer]FirstName$lastName:=[Customer]LastName

POP RECORD([Customer])

//do something with $firstName, $lastName ...

$reference:=[Customer]Reference$firstName:=""$lastName:=""

Begin SQLselect FirstName, LastName from Customerwhere Reference=:$referenceinto :$firstName, :$lastName

End SQL

//do something with $firstName, $lastName ...

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

SQL カレントセレクション・レコードを 変更せずにレコードの値を取り出すことができる

at the end, house of cards falls

Page 259: Code Optimisation

$reference:=[Customer]ReferencePUSH RECORD([Customer])

QUERY([Customer];[Customer]Reference=$reference)$firstName:=[Customer]FirstName$lastName:=[Customer]LastName

POP RECORD([Customer])

//do something with $firstName, $lastName ...

$reference:=[Customer]Reference$firstName:=""$lastName:=""

Begin SQLselect FirstName, LastName from Customerwhere Reference=:$referenceinto :$firstName, :$lastName

End SQL

//do something with $firstName, $lastName ...

PUSH / POP ロジックはとても⾼価な処理 セレクション変更・クエリ・メモリの読み書き…

SQL カレントセレクション・レコードを 変更せずにレコードの値を取り出すことができる

別⾔語の使⽤は⾃由!

at the end, house of cards falls

Page 260: Code Optimisation

a little more knowledge lights our way

Page 261: Code Optimisation

QUERY([Customer];[Customer]LastName="Skywalker")CREATE SET([Customer];"SkywalkerFamilly")

a little more knowledge lights our way

Page 262: Code Optimisation

QUERY([Customer];[Customer]LastName="Skywalker")CREATE SET([Customer];"SkywalkerFamilly")

QUERY+CREATE SET: 2度のネットワーク通信・カレントセレクションの変更・カレントレコードの

変更・カレントレコードのロック

a little more knowledge lights our way

Page 263: Code Optimisation

QUERY([Customer];[Customer]LastName="Skywalker")CREATE SET([Customer];"SkywalkerFamilly")

SET QUERY DESTINATION(Into set;"SkywalkerFamilly")QUERY([Customer];[Customer]LastName="Skywalker")SET QUERY DESTINATION(Into current selection)

QUERY+CREATE SET: 2度のネットワーク通信・カレントセレクションの変更・カレントレコードの

変更・カレントレコードのロック

a little more knowledge lights our way

Page 264: Code Optimisation

QUERY([Customer];[Customer]LastName="Skywalker")CREATE SET([Customer];"SkywalkerFamilly")

SET QUERY DESTINATION(Into set;"SkywalkerFamilly")QUERY([Customer];[Customer]LastName="Skywalker")SET QUERY DESTINATION(Into current selection)

QUERY+CREATE SET: 2度のネットワーク通信・カレントセレクションの変更・カレントレコードの

変更・カレントレコードのロック

SET QUERY DESTINATION+QUERY: 1度のネットワーク通信・セットを作成するだけ

a little more knowledge lights our way

Page 265: Code Optimisation

the sounds of silence, respect you must

Page 266: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

the sounds of silence, respect you must

Page 267: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

the sounds of silence, respect you must

Page 268: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

"parameters" はグローバルセマフォ

the sounds of silence, respect you must

Page 269: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

"parameters" はグローバルセマフォ

"<>arrayParameters" は インタープロセス変数

the sounds of silence, respect you must

Page 270: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

"parameters" はグローバルセマフォ

"<>arrayParameters" は インタープロセス変数

サーバー側で管理

the sounds of silence, respect you must

Page 271: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

"parameters" はグローバルセマフォ

"<>arrayParameters" は インタープロセス変数

サーバー側で管理

クライアント側で管理

the sounds of silence, respect you must

Page 272: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

"parameters" はグローバルセマフォ

"<>arrayParameters" は インタープロセス変数

サーバー側で管理

クライアント側で管理

the sounds of silence, respect you must

Page 273: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("parameters"))IDLE

End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

貴様はテロリストか!

"parameters" はグローバルセマフォ

"<>arrayParameters" は インタープロセス変数

サーバー側で管理

クライアント側で管理

the sounds of silence, respect you must

Page 274: Code Optimisation

While (Semaphore("parameters")) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

ARRAY TEXT(<>arrayParameter;0)

the sounds of silence, respect you must

Page 275: Code Optimisation

While (Semaphore("parameters")) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("$parameters";500)) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("$parameters")

the sounds of silence, respect you must

Page 276: Code Optimisation

While (Semaphore("parameters")) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("$parameters";500)) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("$parameters")

"$parameters" はローカルセマフォ

the sounds of silence, respect you must

Page 277: Code Optimisation

While (Semaphore("parameters")) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("$parameters";500)) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("$parameters")

"$parameters" はローカルセマフォクライアント側で管理

the sounds of silence, respect you must

Page 278: Code Optimisation

While (Semaphore("parameters")) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("parameters")

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("$parameters";500)) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("$parameters")

"$parameters" はローカルセマフォクライアント側で管理

セマフォがセットされるまで500tick待機する

the sounds of silence, respect you must

Page 279: Code Optimisation

ARRAY TEXT(<>arrayParameter;0)

While (Semaphore("$parameters";500)) IDLE End while

APPEND TO ARRAY(<>arrayParameter;$newValue)

CLEAR SEMAPHORE("$parameters")

"$parameters" はローカルセマフォクライアント側で管理

セマフォがセットされるまで500tick待機する

型をしっかり憶えましょう🙂

the sounds of silence, respect you must

Page 280: Code Optimisation

still remains within the sound of silence

Page 281: Code Optimisation

still remains within the sound of silence

Page 282: Code Optimisation

リストボックス#1 セレクション, 特殊型

リストボックス#2 セレクション, 汎⽤型

still remains within the sound of silence

Page 283: Code Optimisation

リストボックス#1 セレクション, 特殊型

リストボックス#2 セレクション, 汎⽤型

still remains within the sound of silence

Page 284: Code Optimisation

リストボックス#1 セレクション, 特殊型

リストボックス#2 セレクション, 汎⽤型

still remains within the sound of silence

Page 285: Code Optimisation

リストボックス#1 セレクション, 特殊型

リストボックス#2 セレクション, 汎⽤型

still remains within the sound of silence

Page 286: Code Optimisation

リストボックス#1 セレクション, 特殊型

リストボックス#2 セレクション, 汎⽤型

still remains within the sound of silence

Page 287: Code Optimisation

リストボックス#1 セレクション, 特殊型

リストボックス#2 セレクション, 汎⽤型

ハイライトセットは必要がある場合にだけ設定 セットの名前に注意を払うこと

still remains within the sound of silence

Page 288: Code Optimisation

kill good old generic

Page 289: Code Optimisation

//$sum:=Array_Sum(->myArray) C_POINTER($1;$array) C_REAL($0)

$array:=$1

ASSERT(\ (Type($array->)=Real array)\ | (Type($array->)=LongInt array)\ | (Type($array->)=Integer array)\ ;"Array must be a numeric")

$sum:=0 For ($i;1;Size of array($array->)) $sum:=$sum+$array->{$i} End for

$0:=$sum

kill good old generic

Page 290: Code Optimisation

//$sum:=Array_Sum(->myArray) C_POINTER($1;$array) C_REAL($0)

$array:=$1

ASSERT(\ (Type($array->)=Real array)\ | (Type($array->)=LongInt array)\ | (Type($array->)=Integer array)\ ;"Array must be a numeric")

$sum:=0 For ($i;1;Size of array($array->)) $sum:=$sum+$array->{$i} End for

$0:=$sum

$sum:=Sum(myArray)

kill good old generic

Page 291: Code Optimisation

//$sum:=Array_Sum(->myArray) C_POINTER($1;$array) C_REAL($0)

$array:=$1

ASSERT(\ (Type($array->)=Real array)\ | (Type($array->)=LongInt array)\ | (Type($array->)=Integer array)\ ;"Array must be a numeric")

$sum:=0 For ($i;1;Size of array($array->)) $sum:=$sum+$array->{$i} End for

$0:=$sum

$sum:=Sum(myArray)

v13以降,"Sum" "Min" "Max" などの統計関数は配列に対応

kill good old generic

Page 292: Code Optimisation

kill good old generic, you can

Page 293: Code Optimisation

ReadWrite(->[Contact])

kill good old generic, you can

Page 294: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

kill good old generic, you can

Page 295: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

v2004では,サーバーをコールしたので,READ WRITEを実⾏する前に 状態を調べることは有⽤だった

kill good old generic, you can

Page 296: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

READ WRITE([Contact])

v2004では,サーバーをコールしたので,READ WRITEを実⾏する前に 状態を調べることは有⽤だった

kill good old generic, you can

Page 297: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

READ WRITE([Contact])

v2004では,サーバーをコールしたので,READ WRITEを実⾏する前に 状態を調べることは有⽤だった

v11以降,リクエストがサーバーに 送信されるまでREAD WRITEは

保留されるようになったのでこれで良い

kill good old generic, you can

Page 298: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

READ WRITE([Contact])

v2004では,サーバーをコールしたので,READ WRITEを実⾏する前に 状態を調べることは有⽤だった

v11以降,リクエストがサーバーに 送信されるまでREAD WRITEは

保留されるようになったのでこれで良い

毎回のアップグレード後に必ずチェックするべき項⽬のひとつ

kill good old generic, you can

Page 299: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

READ WRITE([Contact])

v2004では,サーバーをコールしたので,READ WRITEを実⾏する前に 状態を調べることは有⽤だった

v11以降,リクエストがサーバーに 送信されるまでREAD WRITEは

保留されるようになったのでこれで良い

毎回のアップグレード後に必ずチェックするべき項⽬のひとつ

何年も開いていない汎⽤コードは腐った⾷品と同じ: 捨てるか運を天に任せるか

kill good old generic, you can

Page 300: Code Optimisation

//ReadWrite(->table) C_POINTER($1;$table)

$table:=$1

If (Read only state($table->)) READ WRITE($table->) End if

ReadWrite(->[Contact])

READ WRITE([Contact])

v2004では,サーバーをコールしたので,READ WRITEを実⾏する前に 状態を調べることは有⽤だった

v11以降,リクエストがサーバーに 送信されるまでREAD WRITEは

保留されるようになったのでこれで良い

毎回のアップグレード後に必ずチェックするべき項⽬のひとつ

何年も開いていない汎⽤コードは腐った⾷品と同じ: 捨てるか運を天に任せるか

汎⽤コードがまとめられたコンポーネントも忘れずにチェックすること

kill good old generic, you can

Page 301: Code Optimisation

respect the name, you should

Page 302: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

respect the name, you should

Page 303: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod"+<>myLogin+"_"+string(<>customerID))

respect the name, you should

Page 304: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod"+<>myLogin+"_"+string(<>customerID))

プロセス名は容器ではありません

respect the name, you should

Page 305: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod";<>myLogin;<>customerID)

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod"+<>myLogin+"_"+string(<>customerID))

プロセス名は容器ではありません

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod";<>myLogin;<>customerID)

respect the name, you should

Page 306: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod";<>myLogin;<>customerID)

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod"+<>myLogin+"_"+string(<>customerID))

プロセス名は容器ではありません

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod";<>myLogin;<>customerID)

パラメーター群をサーバーに転送明快なプロセス名

respect the name, you should

Page 307: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod";<>myLogin;<>customerID)

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod"+<>myLogin+"_"+string(<>customerID))

プロセス名は容器ではありません

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod";<>myLogin;<>customerID)

パラメーター群をサーバーに転送明快なプロセス名

奇妙または気まぐれに考案された名前では将来のログ解析が困難に

respect the name, you should

Page 308: Code Optimisation

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod"+<>myLogin+"_"+string(<>customerID))

$ID_Process:=Execute on server("MySrvProcessMethod";0;"MySrvProcessMethod";<>myLogin;<>customerID)

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod"+<>myLogin+"_"+string(<>customerID))

プロセス名は容器ではありません

$ID_Process:=New process("MyProcessMethod";0;"MyProcessMethod";<>myLogin;<>customerID)

パラメーター群をサーバーに転送明快なプロセス名

奇妙または気まぐれに考案された名前では将来のログ解析が困難に

今⾵に,コンテキスト情報はオブジェクト1個で渡せば良い

respect the name, you should

Page 309: Code Optimisation

brothers but not twins …

Page 310: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

brothers but not twins …

Page 311: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while

brothers but not twins …

Page 312: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while

"Execute on server" メソッドに引数を渡せば良い brothers but not twins …

Page 313: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while

"Execute on server" メソッドに引数を渡せば良い

1回にまとめられる

brothers but not twins …

Page 314: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while

"Execute on server" メソッドに引数を渡せば良い

1回にまとめられる

"息継ぎ"する時間がない

brothers but not twins …

Page 315: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while

"Execute on server" メソッドに引数を渡せば良い

1回にまとめられる

"息継ぎ"する時間がない

パラメーターをコマンドに直接 渡すことは避けたほうが良い

brothers but not twins …

Page 316: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

brothers but not twins …

Page 317: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

brothers but not twins …

Page 318: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

brothers but not twins …

Page 319: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

brothers but not twins …

Page 320: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

brothers but not twins …

Page 321: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

"Execute on server"コマンドは⾮同期コール

brothers but not twins …

Page 322: Code Optimisation

$process_srv_id:=Execute on server("myOptimizedMethodSrv";0;"myOptimizedMethodSrv") SET PROCESS VARIABLE($process_srv_id;customer_ID;$1) $calculation_launch:=True SET PROCESS VARIABLE($process_srv_id;calculation_launch;$calculation_launch) $calculation_finished:=False Repeat GET PROCESS VARIABLE($process_srv_id;calculation_finished;$calculation_finished) GET PROCESS VARIABLE($process_srv_id;Result;$Result) Until ($calculation_finished) $calculation_kill:=true SET PROCESS VARIABLE($process_srv_id;calculation_kill;$calculation_kill)

// myOptimizedMethodSrv calculation_launch:=False calculation_finished:=False calculation_kill:=False customer_ID:=0 while( not(calculation_launch)) DELAY PROCESS(Current process;1) End while

// 結果を計算する Result:=....

calculation_finished:=True While (Not(calculation_kill)) DELAY PROCESS(Current process;1) End while //myReallyOptimizedMethodSrv

$customer_ID:=$1 // 結果を計算する $result:=.... $0:=$result

"Execute on server"コマンドは⾮同期コール

"サーバー上で実⾏"メソッド属性は同期コール

brothers but not twins …

Page 323: Code Optimisation

it's free, use it!

Page 324: Code Optimisation

composite indexes, try you must

Page 325: Code Optimisation

筆者がこれまで コンサルティング依頼を

受けたデータベース

composite indexes, try you must

Page 326: Code Optimisation

筆者がこれまで コンサルティング依頼を

受けたデータベース

複合インデックスが 活⽤されていた

データベースの割合

composite indexes, try you must

Page 327: Code Optimisation

筆者がこれまで コンサルティング依頼を

受けたデータベース

複合インデックスが 活⽤されていた

データベースの割合複合インデックスはクエリや並び替えの速度を劇的に改善する可能性がある

composite indexes, try you must

Page 328: Code Optimisation

筆者がこれまで コンサルティング依頼を

受けたデータベース

複合インデックスが 活⽤されていた

データベースの割合複合インデックスはクエリや並び替えの速度を劇的に改善する可能性がある

恩恵にあずかるためにコードを変更する必要はなく, 定義するだけで良い

composite indexes, try you must

Page 329: Code Optimisation

indexes are not only automatic

Page 330: Code Optimisation

indexes are not only automatic

Page 331: Code Optimisation

ポップアップをクリックしてインデックスの種類を選択

indexes are not only automatic

Page 332: Code Optimisation

ポップアップをクリックしてインデックスの種類を選択

少し時間を取ってインデックス設定を⾒直せば,全体の速度を向上させられる

indexes are not only automatic

Page 333: Code Optimisation

ポップアップをクリックしてインデックスの種類を選択

少し時間を取ってインデックス設定を⾒直せば,全体の速度を向上させられる

クラスターを使⽤すればサイズを⼤幅に節約することができ,特に対価はない

indexes are not only automatic

Page 334: Code Optimisation

if no mistake have you made, yet losing you are …

Page 335: Code Optimisation

DESCRIBE QUERY EXECUTION(True)

QUERY BY FORMULA([Flight];([Airport]IATA_AirportCode="SFO")\ & ([Flight]UUID_Line=[Line]UUID) & ([Line]UUID_Airport_To=[Airport]UUID))

$path:=Get last query path(Description in text format) SET TEXT TO PASTEBOARD($path)

DESCRIBE QUERY EXECUTION(False)

if no mistake have you made, yet losing you are …

Page 336: Code Optimisation

DESCRIBE QUERY EXECUTION(True)

QUERY BY FORMULA([Flight];([Airport]IATA_AirportCode="SFO")\ & ([Flight]UUID_Line=[Line]UUID) & ([Line]UUID_Airport_To=[Airport]UUID))

$path:=Get last query path(Description in text format) SET TEXT TO PASTEBOARD($path)

DESCRIBE QUERY EXECUTION(False)

クエリプランとクエリパスで視点をエンジンルーム内に移動

if no mistake have you made, yet losing you are …

Page 337: Code Optimisation

DESCRIBE QUERY EXECUTION(True)

QUERY BY FORMULA([Flight];([Airport]IATA_AirportCode="SFO")\ & ([Flight]UUID_Line=[Line]UUID) & ([Line]UUID_Airport_To=[Airport]UUID))

$path:=Get last query path(Description in text format) SET TEXT TO PASTEBOARD($path)

DESCRIBE QUERY EXECUTION(False)

クエリプランとクエリパスで視点をエンジンルーム内に移動

優れたクエリを書くため,時には直感を働かせることも必要

if no mistake have you made, yet losing you are …

Page 338: Code Optimisation

do not reinvent the wheel, a different game you should play

Page 339: Code Optimisation

do not reinvent the wheel, a different game you should play

Page 340: Code Optimisation

do not reinvent the wheel, a different game you should play

Page 341: Code Optimisation

do not reinvent the wheel, a different game you should play

Page 342: Code Optimisation

do not reinvent the wheel, a different game you should play

Page 343: Code Optimisation

do not reinvent the wheel, a different game you should play

Page 344: Code Optimisation

オブジェクトライブラリで時間を節約・デザインを統⼀・アイデアを共有

do not reinvent the wheel, a different game you should play

Page 345: Code Optimisation

オブジェクトライブラリで時間を節約・デザインを統⼀・アイデアを共有

ライセンス不要,使⽤に制約なし!

do not reinvent the wheel, a different game you should play

Page 346: Code Optimisation

4D helps your progress

Page 347: Code Optimisation

4D helps your progress

Page 348: Code Optimisation

4D helps your progress

Page 349: Code Optimisation

Mr Smith

VAT rate

4D helps your progress

Page 350: Code Optimisation

$id_progress:=Progress New Progress SET BUTTON ENABLED ($id_progress;True) Progress SET TITLE ($id_progress;"Update customers";0;"";True) ALL RECORDS([Customer]) $j:=0 $nb:=Records in table([Customer]) While (Not(End selection([Customer]))) & (Not(Progress Stopped ($id_progress))) $j:=$j+1 Progress SET PROGRESS ($id_progress;$j/$nb;[Customer]name)

/// ...

NEXT RECORD([Customer]) End while

Progress QUIT ($id_progress)

Mr Smith

VAT rate

4D helps your progress

Page 351: Code Optimisation

$id_progress:=Progress New Progress SET BUTTON ENABLED ($id_progress;True) Progress SET TITLE ($id_progress;"Update customers";0;"";True) ALL RECORDS([Customer]) $j:=0 $nb:=Records in table([Customer]) While (Not(End selection([Customer]))) & (Not(Progress Stopped ($id_progress))) $j:=$j+1 Progress SET PROGRESS ($id_progress;$j/$nb;[Customer]name)

/// ...

NEXT RECORD([Customer]) End while

Progress QUIT ($id_progress)

Mr Smith

VAT rate

$id_progress:=Progress New Progress SET BUTTON ENABLED ($id_progress;True) Progress SET TITLE ($id_progress;"Apply new parameter";0;"";True) ALL RECORDS([Param]) $j:=0 $nb:=Records in table([Param]) While (Not(End selection([Param]))) & (Not(Progress Stopped ($id_progress))) $j:=$j+1 Progress SET PROGRESS ($id_progress;$j/$nb;[Param]name)

/// ...

NEXT RECORD([Param]) End while

Progress QUIT ($id_progress)

4D helps your progress

Page 352: Code Optimisation

$id_progress:=Progress New Progress SET BUTTON ENABLED ($id_progress;True) Progress SET TITLE ($id_progress;"Update customers";0;"";True) ALL RECORDS([Customer]) $j:=0 $nb:=Records in table([Customer]) While (Not(End selection([Customer]))) & (Not(Progress Stopped ($id_progress))) $j:=$j+1 Progress SET PROGRESS ($id_progress;$j/$nb;[Customer]name)

/// ...

NEXT RECORD([Customer]) End while

Progress QUIT ($id_progress)

Mr Smith

VAT rate

$id_progress:=Progress New Progress SET BUTTON ENABLED ($id_progress;True) Progress SET TITLE ($id_progress;"Apply new parameter";0;"";True) ALL RECORDS([Param]) $j:=0 $nb:=Records in table([Param]) While (Not(End selection([Param]))) & (Not(Progress Stopped ($id_progress))) $j:=$j+1 Progress SET PROGRESS ($id_progress;$j/$nb;[Param]name)

/// ...

NEXT RECORD([Param]) End while

Progress QUIT ($id_progress)おすすめ:

ループ10回毎にメソッドをコールする

4D helps your progress

Page 353: Code Optimisation

don't keep a dog and bark yourself!

Page 354: Code Optimisation

don't keep a dog and bark yourself!

Page 355: Code Optimisation

C_POINTER($1;$2)C_LONGINT($nb_total)

ARRAY TEXT($_result;0x0000)CLEAR VARIABLE($nb_total)

$nb:=Size of array($1->)For ($i;1;$nb)

If (Length($1->{$i})=0)Else

APPEND TO ARRAY($_result;$1->{$i})$nb_total:=$nb_total+1

End ifEnd for

COPY ARRAY($_result;$2->)

don't keep a dog and bark yourself!

Page 356: Code Optimisation

C_POINTER($1;$2)C_LONGINT($nb_total)

ARRAY TEXT($_result;0x0000)CLEAR VARIABLE($nb_total)

$nb:=Size of array($1->)For ($i;1;$nb)

If (Length($1->{$i})=0)Else

APPEND TO ARRAY($_result;$1->{$i})$nb_total:=$nb_total+1

End ifEnd for

COPY ARRAY($_result;$2->)

がんばり過ぎ〜$nb_total:=0

のほうが⾃然なのに

この変数は要らないのでは

$1->{$i}="" よりも 優れているのかなぁ?=0 / Else よりも #0 のほうが

シンプルじゃないの?

don't keep a dog and bark yourself!

Page 357: Code Optimisation

Antoine de Saint Exupéry

La perfection est atteinte, non pas lorsqu'il n'y a plus rien à ajouter, mais lorsqu'il n'y a plus rien à retirer.

Wind, Sand and Stars (1939)