Oren Eini

aka Ayende Rahien

Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,616
|
Comments: 51,246

Copyright ©️ Ayende Rahien 2004 — 2025

Privacy Policy · Terms
filter by tags archive
RavenDB Workshops - Deep dive into practical use of Document Data Modeling

Geo Location & Spatial Searches with RavenDB–Part VI–Database Modeling

time to read 2 min | 345 words

If you had sharp eyes, you might have noticed that in this code, I am actually using two different sessions:

We have the GeoSession, and we have the RavenSession.

The GeoSession is actually pointed at a different database, and it is a read only. In fact, here is how we use this:

image

As you can see, we create this on as needed basis, and we only dispose it, we never actually call SaveChanges().

So, those are the technical details, but what is the reasoning behind this?

Well, it is actually pretty simple. The GeoIP dataset is about 600 MB in size, and mostly it is about... well, geo location stuff. It is a very nice feature, but it is a self contained one, and not something that I really care for putting inside my app database. Instead, I have decided to go another way, and use a separate database.

That means that we have separation, at the data layer, between the different databases. It makes sense, about the only thing that we need from the GeoIP dataset is the ability to handle queries, and that is expressed only via GetLocationByIp, nothing more.

I don’t see a reason to make the app database bigger and more complex, or to have to support updates to the GeoIP dataset inside the app. This is a totally separate service. And having this in a separate database make it much easier to use this the next time that I want to use geo location. And it simplify my life right now with regards to maintaining and working with my current app.

In fact, we could have taken it even further, and not use RavenDB access to this at all. We can use REST calls to get the data out directly. We have chosen to still use the RavenDB Client, I’ll discuss exactly why we chose not to do that.

Tweet 6 comments

Related posts that you may find interesting:

20 Jun 2012 Geo Location & Spatial Searches with RavenDB–Part III-Importing
24 Jul 2013 Reviewing Lightning memory-mapped database library: going deeper
18 Dec 2017 Queries++ in RavenDB: Spatial searches

Comments

tobi

If OnActionExecuted opens the read-only session using the lazy-initializer mechanism, it won't be disposed. The using block captures the given value on enter, and it would capture a null. Even if OnActionExecuted does not use the session, it is a code-smell.

Just focusing on the most unimportant part of the post here, in good tradition.

Ayende Rahien

Tobi, Um.... Nope.

OnActionExecuted happens after the action has been run, if it used the geoSession, it will be disposed.

kalki

if geoip database was freeware/opensource, if yes could you pls share the provider.

Ayende Rahien

Kalki, I shared the code in the blog posts, and I pointed where you can get the database for free

tobi

Ayende,

what use is the using-block if nothing happens inside of it? Just dispose the thing if it has been created.

Ayende Rahien

Tobi, Pretty much, yes.

Comment preview

Comments have been closed on this topic.

Markdown formatting

ESC to close

Markdown turns plain text formatting into fancy HTML formatting.

Phrase Emphasis

*italic* **bold**
_italic_ __bold__

Links

Inline:

An [example](http://url.com/ "Title")

Reference-style labels (titles are optional):

An [example][id]. Then, anywhere
else in the doc, define the link:
 [id]: http://example.com/ "Title"

Images

Inline (titles are optional):

![alt text](/path/img.jpg "Title")

Reference-style:

![alt text][id]
[id]: /url/to/img.jpg "Title"

Headers

Setext-style:

Header 1
========
Header 2
--------

atx-style (closing #'s are optional):

# Header 1 #
## Header 2 ##
###### Header 6

Lists

Ordered, without paragraphs:

1. Foo
2. Bar

Unordered, with paragraphs:

* A list item.
 With multiple paragraphs.
* Bar

You can nest them:

* Abacus
 * answer
* Bubbles
 1. bunk
 2. bupkis
 * BELITTLER
 3. burper
* Cunning

Blockquotes

> Email-style angle brackets
> are used for blockquotes.
> > And, they can be nested.
> #### Headers in blockquotes
> 
> * You can quote a list.
> * Etc.

Horizontal Rules

Three or more dashes or asterisks:

---
* * *
- - - - 

Manual Line Breaks

End a line with two or more spaces:

Roses are red, 
Violets are blue.

Fenced Code Blocks

Code blocks delimited by 3 or more backticks or tildas:

```
This is a preformatted
code block
```

Header IDs

Set the id of headings with {#<id>} at end of heading line:

## My Heading {#myheading}

Tables

Fruit |Color
---------|----------
Apples |Red
Pears	 |Green
Bananas |Yellow

Definition Lists

Term 1
: Definition 1
Term 2
: Definition 2

Footnotes

Body text with a footnote [^1]
[^1]: Footnote text here

Abbreviations

MDD <- will have title
*[MDD]: MarkdownDeep

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. Recording (18):
    29 Sep 2025 - How To Run AI Agents Natively In Your Database
  2. Webinar (8):
    16 Sep 2025 - Building AI Agents in RavenDB
  3. RavenDB 7.1 (7):
    11 Jul 2025 - The Gen AI release
  4. Production postmorterm (2):
    11 Jun 2025 - The rookie server's untimely promotion
  5. RavenDB News (2):
    02 May 2025 - May 2025
View all series

Syndication

Main feed ... ...
Comments feed ... ...
}

AltStyle によって変換されたページ (->オリジナル) /