都内で働くSEの技術的なひとりごと / Technical soliloquy of System Engineer working in Tokyo

都内でサラリーマンやってます。SQL Server を中心とした (2023年からは Azure も。) マイクロソフト系(たまに、OSS系などマイクロソフト以外の技術も...)の技術的なことについて書いています。日々の仕事の中で、気になったことを技術要素関係なく気まぐれに選んでいるので記事内容は開発言語、インフラ等ばらばらです。なお、当ブログで発信、発言は私個人のものであり、所属する組織、企業、団体等とは何のかかわりもございません。ブログの内容もきちんと検証して使用してください。英語の勉強のため、英語の

Useful SQL functions, syntax, and more - Part 19 (FAST?)

Recently I started working on SQL Server just a little bit on side job. Tuning is an area that I personally like very much because it's like putting the puzzle back together. While doing some research, I found a query hint that I'd never used called "FAST".

FAST number_rows
Specifies that the query is optimized for fast retrieval of the first number_rows. This result is a nonnegative integer. After the first number_rows are returned, the query continues execution and produces its full result set.

Is there anything this convenient for the keyword "fast search"? But I was interested in it, so I'll check out how it works as soon as possible. I'll use the following query.

SELECT 
    SOH.SalesOrderID,
    SOH.CustomerID,
    SOH.SalesPersonID
FROM 
    Sales.SalesOrderHeader SOH
WHERE 
    SalesPersonID = 279;

Above execution plan as follows.
f:id:koogucc11:20200831201858p:plain

Next, let's add OPTION (FAST n). n = 100.

SELECT
    SOH.SalesOrderID,
    SOH.CustomerID,
    SOH.SalesPersonID
FROM 
    Sales.SalesOrderHeader SOH
WHERE 
    SalesPersonID = 279
OPTION (FAST 100);

 Above Execution plan as follows.
f:id:koogucc11:20200831201946p:plain

Let's compare the two plans. The number of rows is different and the cost is lower with OPTION (FAST 100) added.
f:id:koogucc11:20200831202923p:plain

The estimated number of rows is different. The one with OPTION (FAST 100) has 100. There is an attribute "EstimateRowsWithoutRowGoal = 429" that I've never seen before. (My knowledge of SQL Server stops at version 2012, but I don't remember this being around for a long time.)
f:id:koogucc11:20200831203652p:plain

The estimated number of rows has been reduced here as well, and "EstimateRowsWithoutRowGoal = 31465" has been added.
f:id:koogucc11:20200831204006p:plain

Hmmm, I haven't written an article in a while, but I'm halfway through. But I guess this is convenient because it's a good story to write an article about above, lol.

便利な SQL の関数とか、構文とか、その他色々まとめてみる - その19 (FASTって?)

 最近、副業でほんの少しだけ SQL Server のお仕事を開始しました。チューニングは、パズルを組みなおすような作業なので個人的に非常に好きな分野です。色々調べものをしていたら、FAST という使ったことのないクエリヒントを見つけました。

FAST number_rows
最初の number_rows を高速検索するためにクエリの最適化を行うことを指定します。 この結果は負以外の整数です。 最初の number_rows を返した後、クエリは実行を続け、完全な結果セットを作成します。

 高速検索というキーワードにこんな都合がいいものあるんかいな?と思いながらも興味を持ったので、早速動作をチェックしてみます。下記のクエリを使用します。

SELECT 
    SOH.SalesOrderID,
    SOH.CustomerID,
    SOH.SalesPersonID
FROM 
    Sales.SalesOrderHeader SOH
WHERE 
    SalesPersonID = 279;

 実行プランは下図の通りです。
f:id:koogucc11:20200831201858p:plain

 次に、OPTION (FAST n) を付加してみましょう。n = 100 にしておきます。

SELECT
    SOH.SalesOrderID,
    SOH.CustomerID,
    SOH.SalesPersonID
FROM 
    Sales.SalesOrderHeader SOH
WHERE 
    SalesPersonID = 279
OPTION (FAST 100);

 実行プランは下図の通りです。
f:id:koogucc11:20200831201946p:plain

 二つのプランを比較してみましょう。件数が違っていたり、Cost が OPTION (FAST 100) を付加したほうが低くなってますね。
f:id:koogucc11:20200831202923p:plain

 推定行数が異なっていますね。OPTION (FAST 100) を付加したほうは 100件になっています。しかも、付加した方には EstimateRowsWithoutRowGoal = 429 とか見たことない属性があります。(知識が 2012 で止まっているのですが、こんなの昔からあったっけ?)
f:id:koogucc11:20200831203652p:plain

 こちらも推定行数が減っており、EstimateRowsWithoutRowGoal = 31465 が付加されています。
f:id:koogucc11:20200831204006p:plain

 うーん、久しぶりに記事を書いてみたけど、中途半端に終わってしまった。しかし、これは記事を書くネタになるから都合がいいかな笑

 

Finding various software to make iPad sub-display

I forgot to write the English version of the article. I wrote early in the morning of May 5.

                      • -

This is my first article in a while. I hadn't written a article at all since I wrote my New Year's resolutions.
ryuchan.hatenablog.com

I haven't achieved what I had resoluted for at all. Ugh.

Here are my resolutions for this year. Write blogs regularly and publish technical information. Learn English every day and use it for my work.

New year’s resolution - 都内で働くSEの技術的なひとりごと / Technical soliloquy of System Engineer working in Tokyo

Due to "Corona Virus", Golden Week was turned into Gaman Week ("Gaman" means endurance.) as some governor had sent out by e-mail. Today (May 4), a state of emergency was declared extended until May 31. It looks like I'll still be WFH. The only way to achieve our goals is to improve efficiency, since I mostly work on a PC, so the only way to improve efficiency is to make iPad multi-display. Multi-display is a must. After the state of emergency was declared, I purchased one unsold display at an appliance store.
https://www.biccamera.com/bc/item/5286471/

However, there are many things that i want to keep open at all times while working, such as email, Teams, Twitter? Youtube? Facebook? It's annoying to switch between multiple applications. I want more sub-displays! So, I tried out four sub-display tools this time.

  • Sidecar
  • Duet Display
  • Yam Display
  • spacedesk

Sidecar connects to iPad from macOS and is very responsive and functional. However, the MAC has been taken over by my kid's cram school for online classes, so I can no longer use it at work.
f:id:koogucc11:20200504200840j:plain

Duet Display was probably very much in use on macOS until Sidecar was released. There are many items that can be configured, and it is as good as Sidecar. However, it's wired, and if i buy Duet Air, can do it wirelessly...
f:id:koogucc11:20200504201514j:plain

Yam Display is only for macOS, so I can't use it this time, unfortunately. So, I tried the last spacedesk and it fit my home requirements perfectly. What's more, it's free! The OS is limited to Windows. In addition, since the connection is via LAN, the sub-display device (iPad etc) must be connected to the same segment of LAN. In some companies, it may be difficult to connect personal devices to the company network, but this time it was not a problem at all because i'am WFH now. So, let's set it up quickly.

First, install the server function on the PC from which i want to connect. The application will be installed as below.
f:id:koogucc11:20200504205007p:plain

Next, install the Multi Monitor App on your iPad, which will be sub-display. After the installation, set the IP address of the PC on which the server function is installed.
f:id:koogucc11:20200504205922j:plain

After setting it up, can make it a sub-display by clicking on the red frame part of the tool.
f:id:koogucc11:20200504210143j:plain

As a result, my home environment looks like below, with a 5 sub-display lol.
f:id:koogucc11:20200504210603p:plain

Even with all these features, spacedesk is free software. Great!

I recently bought a new oven toaster. It's stylish, multi-functional and very easy to use. I highly recommend it.

クイジナートノンフライ オーブントースター TOA-28J

クイジナートノンフライ オーブントースター TOA-28J

  • 発売日: 2019/10/25
  • メディア: ホーム&キッチン
www.cuisinart.jp

iPad をサブディスプレイ化するソフトをいろいろ探してみた

 久ぶりの投稿です。新年の抱負を書いて以来、まったく記事を書いていませんでした。
ryuchan.hatenablog.com

 抱負としてあげていたこともまったく達成できていません。ううっ。

今年の抱負をあげます。 定期的にブログを書き、技術情報を公開すること。 毎日英語を勉強し、仕事に役立てること。

今年の抱負を書いてみた - 都内で働くSEの技術的なひとりごと / Technical soliloquy of System Engineer working in Tokyo

 コロナウィルスの影響でゴールデンウイーク (GW) は、どこかの知事がメール配信していたようにガマンウィーク (GW) になってしまいました。本日 (5/4) に緊急事態宣言が 5/31 まで延長されました。在宅でのお仕事もまだまだ続きそうです。在宅で子供の面倒や家事などをしながらだと、仕事に集中する時間も限られますので、目標を達成するには効率をあげるしかありません。PC での作業が中心なので、効率を向上させるには....."マルチディスプレイ化" が必須です。緊急事態宣言後、家電量販店で売れ残っていたディスプレイを一台買いました。
https://www.biccamera.com/bc/item/5286471/

 しかし、メール, Teams, Twitter?, Youtube?, Facebook?, 各種アプリ画面等々仕事中に常時開いておきたいものは多数あります。複数のアプリケーションを切り替えるのは億劫です。もっとサブディスプレイがほしい!というわけで、今回 4 つほどサブディスプレイツールを試してみました。

  • Sidecar
  • Duet Display
  • Yam Display
  • spacedesk

 Sidecar は、macOS から iPad に接続するもので、レスポンス・機能ともに非常に優れています。ただ、mac は子供の塾でオンライン授業を行うことになったため、占有されてしまい、仕事で使うことができなくなりました。
f:id:koogucc11:20200504200840j:plain

 Duet Display は、Sidecar がリリースされるまでは、macOS で非常に多くの人が使っていたかと思います。設定できる項目も多く、Sidecar に引けを取らない感じです。ただ、有線なんですよね。Duet Air を購入すれば無線でも可能になるんですが....
f:id:koogucc11:20200504201514j:plain

 Yam Display は、macOS 専用なので、今回は残念ながら使えません。そこで、最後の spacedesk を試してみたんですが、私の在宅要件にぴったりはまりました。しかも、無料!接続元の OS は Windows に限られます。また、LAN 経由での接続になるため、サブディスプレイとなる機器 (iPad) などが、同一セグメントの LAN に接続している必要があります。会社では個人機器を社内ネットワークにつなぐのは難しいケースもあるかと思いますが、今回は在宅なので全く問題ありません。それでは、早速セットアップしてみましょう。

 まず、接続元となる PC にサーバー機能をインストールします。下図のようなアプリケーションがインストールされます。
f:id:koogucc11:20200504205007p:plain

 次に、サブディスプレイとなる iPad などに Multi Monitor App をインストールします。インストール後に、サーバー機能をインストールされた PC の IP アドレスを設定します。
f:id:koogucc11:20200504205922j:plain

 設定後、ツールの赤枠部分をクリックすることで、サブモニタ化することができます。
f:id:koogucc11:20200504210143j:plain

 結果、私の在宅環境は下図のようになりました。5面ディスプレイ笑
f:id:koogucc11:20200504210603p:plain

 これだけの機能があり、フリーソフトとは。恐るべし、spacedesk!

 最近、オーブントースターを買い換えました。これ、見た目おしゃれで、多機能で、すごく使いやすいです。お勧めです。

クイジナートノンフライ オーブントースター TOA-28J

クイジナートノンフライ オーブントースター TOA-28J

  • 発売日: 2019/10/25
  • メディア: ホーム&キッチン
www.cuisinart.jp

New year’s resolution

A happy new year! I haven't written an article for a long time. I watch HAKONE EKIDEN, and at the same time, I write this article.
Last year, I changed a job and the technology I use has also changed. The OS changed from Windows to Redhat and CentOS, the virtual environment changed from Hyper-V to VMware Hypervisor, the development language changed from C # to Java, and the cloud environment changed from Azure to AWS. Recently, I have been playing with IncommingWebhook of Microsoft Teams with curl command.

Here are my resolutions for this year.

  • Write blogs regularly and publish technical information.
  • Learn English every day and use it for my work.
  • Learn Linux.
  • Learn VMware.
  • Learn global operations at a foreign company.

I would like to make the above five points new year's resolutions. When I was looking at the Hakone Ekiden, I wanted shoes lol.

今年の抱負を書いてみた

 あけましておめでとうございます。今年もよろしくお願いします。久しぶりの投稿です。箱根駅伝を見ながら、記事を書いています。去年は会社も変わり、それに伴い扱う技術も大きく変化しました。OS は、Windows から、Redhat, CentOS となり、仮想環境は Hyper-V から VMware Hypervisor となり、開発言語は C# から Java となり、そしてクラウド環境は Azure から AWS となりました。最近は、curl コマンドで Teams の IncommingWebhook とか使って遊んでいます。

 今年の抱負をあげます。

  • 定期的にブログを書き、技術情報を公開すること。
  • 毎日英語を勉強し、仕事に役立てること。
  • Linux を勉強すること。
  • VMware を勉強すること。
  • 外資系企業でグローバルオペレーションを学ぶこと。

 上記、4点を抱負にしたいと思います。箱根駅伝見ていたら、シューズ 欲しくなってきた。