ホームページ データベース mysql チュートリアル MongoDB Tip: Create Short Field Names

MongoDB Tip: Create Short Field Names

Jun 07, 2016 pm 04:29 PM
create mongodb short

MongoDB’s dynamic schema and document-based data structure offer a lot of flexibility in development, but it’s important to understand how your document construction can affect available memory in your application. It’s incredibly valua

MongoDB’s dynamic schema and document-based data structure offer a lot of flexibility in development, but it’s important to understand how your document construction can affect available memory in your application. It’s incredibly valuable to optimize storage size of your documents, and one easy way to do this is by shortening your field names.

MongoDB stores all field names in each BSON document. In most cases the space is inconsequential, but when your data set grows to include millions of documents (and potentially collections), the extra bytes in long field names can add up. If document or schema overhead is a significant concern, consider shortening your field names.

For example, instead of the field names in the following document:

{ first_name: ?“Joseph”, address: “345 Caroll Street” , telephone: “19176253475”}
ログイン後にコピー


Consider shortening the names to:

{ fname: ?“Joseph”, addr: “345 Caroll Street” , tel: “19176253475”}
ログイン後にコピー


The Use Case

One case where this might be useful is when you are logging real-time data points such as web stats. Here, you have many small documents being added every minute, second and hour of the day. You might have a document that looks like this:

{"_id" : "512d35b0400fed3b997cd9c9" ,
ログイン後にコピー
ログイン後にコピー
"hour" : "Thu Mar 05 2013 10:00:00 GMT-0500 (EST)" ,
ログイン後にコピー
"site" : "abc" , "u" : 1 ,
ログイン後にコピー
"pageviews" : 1}
ログイン後にコピー


Having longer field names could end up taking up a lot of disk space over time, while using shorter field names with have a larger impact on your disk savings. Consider cutting down your field names like so:

{"_id" : "512d35b0400fed3b997cd9c9" ,
ログイン後にコピー
ログイン後にコピー
"h" : "Thu Mar 05 2013 10:00:00 GMT-0500 (EST)" ,
ログイン後にコピー
"s" : "abc" , "u" : 1 ,
ログイン後にコピー
"pv" : 1}
ログイン後にコピー


Depending on your document size, using shorter field names will have a tangible benefit to your application.

  • Learn more about MongoDB for Analytics

Update: Here is a link to the two server tickets that are being worked on to optimize document storage at the database level.?

  • SERVER-863
  • SERVER-164
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

mongodb ではどのバージョンが一般的に使用されますか? mongodb ではどのバージョンが一般的に使用されますか? Apr 07, 2024 pm 05:48 PM

最新の機能と改善が提供される MongoDB の最新バージョン (現在 5.0) を使用することをお勧めします。バージョンを選択するときは、機能要件、互換性、安定性、コミュニティ サポートを考慮する必要があります。たとえば、最新バージョンにはトランザクションや集計パイプラインの最適化などの機能が備わっています。バージョンがアプリケーションと互換性があることを確認してください。運用環境の場合は、長期サポート バージョンを選択してください。最新バージョンでは、より積極的なコミュニティサポートが提供されています。

Nodejsとvuejsの違い Nodejsとvuejsの違い Apr 21, 2024 am 04:17 AM

Node.js はサーバー側の JavaScript ランタイムであり、Vue.js は対話型ユーザー インターフェイスを作成するためのクライアント側の JavaScript フレームワークです。 Node.js はバックエンド サービス API 開発やデータ処理などのサーバー側開発に使用され、Vue.js はシングルページ アプリケーションや応答性の高いユーザー インターフェイスなどのクライアント側開発に使用されます。

mongodb によって作成されたデータベースはどこにありますか? mongodb によって作成されたデータベースはどこにありますか? Apr 07, 2024 pm 05:39 PM

MongoDB データベースのデータは、ローカル ファイル システム、ネットワーク ファイル システム、またはクラウド ストレージに配置できる指定されたデータ ディレクトリに保存されます。具体的な場所は次のとおりです: ローカル ファイル システム: デフォルトのパスは Linux/macOS: /data/db、Windows: C:\data\db。ネットワーク ファイル システム: パスはファイル システムによって異なります。クラウド ストレージ: パスはクラウド ストレージ プロバイダーによって決定されます。

mongodbデータベースの利点は何ですか mongodbデータベースの利点は何ですか Apr 07, 2024 pm 05:21 PM

MongoDB データベースは、その柔軟性、スケーラビリティ、および高いパフォーマンスで知られています。その利点には、データを柔軟かつ非構造化された方法で保存できるドキュメント データ モデルが含まれます。シャーディングによる複数サーバーへの水平スケーラビリティ。クエリの柔軟性により、複雑なクエリと集計操作をサポートします。データ レプリケーションとフォールト トレランスにより、データの冗長性と高可用性が確保されます。 JSON サポートにより、フロントエンド アプリケーションと簡単に統合できます。大量のデータを処理する場合でも高速な応答を実現する高いパフォーマンス。オープンソースでカスタマイズ可能で無料で使用できます。

mongodb とはどういう意味ですか? mongodb とはどういう意味ですか? Apr 07, 2024 pm 05:57 PM

MongoDB は、大量の構造化データと非構造化データを保存および管理するために使用されるドキュメント指向の分散データベース システムです。その中心的な概念にはドキュメントのストレージと配布が含まれ、その主な機能には動的スキーマ、インデックス作成、集約、マップリデュース、レプリケーションが含まれます。コンテンツ管理システム、電子商取引プラットフォーム、ソーシャル メディア Web サイト、IoT アプリケーション、モバイル アプリケーション開発で広く使用されています。

mongodbを開く方法 mongodbを開く方法 Apr 07, 2024 pm 06:15 PM

Linux/macOS の場合: データ ディレクトリを作成し、「mongod」サービスを開始します。 Windows の場合: データ ディレクトリを作成し、Service Manager から MongoDB サービスを開始します。 Docker の場合: 「docker run」コマンドを実行します。他のプラットフォームの場合: MongoDB のドキュメントを参照してください。確認方法: 「mongo」コマンドを実行して接続し、サーバーのバージョンを確認します。

mongodb データベース ファイルはどこにありますか? mongodb データベース ファイルはどこにありますか? Apr 07, 2024 pm 05:42 PM

MongoDB データベース ファイルは、MongoDB データ ディレクトリにあります。デフォルトでは /data/db です。このディレクトリには、.bson (ドキュメント データ)、ns (コレクション情報)、journal (書き込み操作レコード)、wiredTiger (WiredTiger 使用時のデータ) が含まれています。ストレージ エンジン ) および config (データベース構成情報) およびその他のファイル。

navicat の有効期限が切れた場合の対処方法 navicat の有効期限が切れた場合の対処方法 Apr 23, 2024 pm 12:12 PM

Navicat の有効期限の問題を解決するには、ライセンスを更新する、自動更新を無効にする、Navicat プレミアム エッセンシャルの無料バージョンを使用する、などがあります。

See all articles