Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 18 | Comments: 87

filter by tags archive

Streamlined RavenDB, Part I

time to read 2 min | 312 words

One of the things that we worked very hard on (and are still working very hard) is making RavenDB as streamlined as possible, in the sense of making it very easy to do things that you commonly have to do.

Case in point, the Future Posts feature of this blog. Yesterday I went a bit overboard and posted about 10 posts in the space of two hours. (No, this isn’t my usual rate). That led to something that I didn’t quite foreseen:

image

We did have a limit on the number of future posts that we will show, but that limit was set to 15, and as you can see, it is actually pretty hard to look at things when we have so many, so instead I decided that we should have the following:

image

Just a minor UI change, but we now need to also change the data that we gather, or do we? Let us look at the code:

image

The only change that I actually had to do was modify the Take() from 15 to 5, and also ask the query to give me the query statistics. Because such as operation (pages + full count) is so common, RavenDB make it super cheap to do so. You don’ t need to issue a separate query, and you don’t need to do anything nor are you incurring any additional costs.

The information is already there.


Comments

Scooletz

Nice. I do like the way of getting things done with Raven. Write a dot and check what features are provided. By the way, are all this extensions (like cache and stats) written in a feature-mode you often describe? Is it a vertical, from the client to the raven server implementation?

Ayende Rahien

Scooletz, Some of them are, bundles, for example. Some are more complex, caching for example, requires us to take explicit action in several places, as did profiling. It really depend on what you are doing, and what extensions points we have there to cover them.

Idsa

So I guess usual paging also may be implemented by one query? Nice, never liked the absense of this feature in other database servers.

Ayende Rahien

Idsa, Yep, that is a single call away, and requires no extra work

Daniel Lidström

Where is the 8 coming from? Are you calculating it in the view?

Ayende Rahien

Daniel, It is TotalResults - Posts.Count

Daniel Lidström

Ok thanks, that clarified things a bit for me.

Bogdan Marian

@Ayende Hats on, master! I really, really like the total count + page in the same query... By the way, what are you using behind the call MapTo? AutoMapper or something else?

Bogdan Marian

@Ayende Are you not concerned by the price of using AutoMapper? As far as I know, it's using Reflection for mapping ...

Ayende Rahien

Bogdan, In a word, no. http://ayende.com/blog/4811/performance-numbers-in-the-pub

James Morcom

My main concern with automapper is that renaming a property on my entity could break my views without me realising it - as the corresponding property on the viewmodel won't be renamed.

Marcel Medak

Hi Ayende, I see that you explicitly query for posts which are not flagged as deleted. I suppose that most of the time only posts are queried which aren't flagged as deleted and that this must be done explicitly. So my question is if this is something you can avoid?

Ayende Rahien

Marcel, Actually, yes, we could have created an index that would do this filtering for us, certainly.

Gian Maria Ricci

Man, this is really really really coool!!!!!

Mario

Ayende for a long time I would love ask you ...why is Mark Zuckerberg the creator of FB but and not you???

p.s. sometimes (when I have no money) I think mmm ...why i'm not the creator of FB :( ...then I think mmm ...but ayende is not even :)

Tang Biao

Sorry to ask a junior question, is the source code that contains this sample on github, and which repository? I feel like to take a look.

Bas
Bas

During 1 minute the post is not shown as public post and not as future post. See also: http://ayende.com/blog/26625/you-canrsquo-t-cache-datetime-now

Ayende Rahien

Bas, That is okay, it is perfectly fine or this to happen, since the cost of avoiding it may be too high.

Bas
Bas

What is the cost of changing < into <= in WhereIsPublicPost() or changing > into >= in FuturePosts()

Ayende Rahien

Bas, That isn't the issue, the issue is that they are using slightly different clocks to do that. It may be that they hit just in the 1 minute mark, and get two different minutes

Ayende Rahien

Tang,

http://github.com/ayende/RaccoonBlog

Jeff Handley

By having the .Statistics call before the .Where(x => x.IsDeleted == false), does that make the statistics include deleted posts in the counts?

Ayende Rahien

Jeff, No, it doesn't matter where you put the Statistics call

Tang Biao

Thanks, ayende. Just started to follow your blogs. It has so many things to learn.

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. Buffer allocation strategies: A possible solution - 2 days from now
  2. Buffer allocation strategies: Explaining the solution - 3 days from now
  3. Buffer allocation strategies: Bad usage patterns - 4 days from now
  4. The useless text book algorithms - 5 days from now
  5. Find the bug: The concurrent memory buster - 6 days from now

There are posts all the way to Sep 11, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    03 Sep 2015 - The industry at large
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats