DayPilot Forums

DayPilot is the best open-source Outlook-like calendar control for ASP.NET.
DayPilot Pro Demo (Calendar control)
» DayPilot Pro live demo (Calendar control)
DayPilot Pro Demo (Scheduler control)
» DayPilot Pro live demo (Scheduler control)
Home » General » DayPilot SQL Sample application

DayPilot SQL Sample application

Hello,

In your sample there is this SQL string :
SELECT [id]....[allday] FROM [event] WHERE NOT ([eventstart]<=@start OR [eventend] >= (@end))

Is is better for performances to have a select from hours in a different field (date field and hour field) or a full date field ?
Also, why not use a 'WHERE >= <=' statement instead of WHERE NOT ?

Thanks
Anonymous - 11/8/2007 11:16:59 AM
I guess there will be no difference in performance between using separated or joint date and time fields. DayPilot needs it in one field so you might loose some nanoseconds when joining them during the select but you won't notice.

It's possible to rewrite the condition like this:

WHERE ([eventstart] >= @start AND [eventstart] <= @end) OR ([eventend] >= @start AND [eventend] <= @end)

This one is probably easier to understand but much longer.
Dan Letecky - 11/8/2007 4:08:08 PM
WHERE NOT is slower than WHERE for this query ?

My next application will be a Planning so it will be a performance issue.

Thanks :)
Anonymous - 11/8/2007 4:19:19 PM
But now I see that the original code is not quite right, it should read like this:

WHERE NOT (([eventend <= @start) OR ([eventstart] >= @end))

and the alternative should read like this:

WHERE ([eventstart] >= @start AND [eventstart] < @end) OR ([eventend] > @start AND [eventend] <= @end)

I'll fix it in the demo.
Dan Letecky - 11/8/2007 4:22:05 PM
The query will go through the SQL Server optimizer first anyway so I'm sure both options will execute with the same speed.

I wouldn't loose much time with the SQL query until the resulting speed is unsatisfactory.
Dan Letecky - 11/8/2007 4:29:30 PM
But start with setting indexes on both eventstart and eventend fields, that will speed things up.
Dan Letecky - 11/8/2007 4:31:30 PM
Thank you very much for your answers.
Anonymous - 11/8/2007 4:31:39 PM

How about using SQL BETWEEN?

i.e.

WHERE
(EventFrom BETWEEN @startDate and @endDate)
OR
(EventToBETWEEN @startDate and @endDate)
)

John - 7/7/2008 8:27:12 PM

What I'm not sure of, is how to update the Parameters of the ASP SQLdataSource I use to populate the DayPilotSchedule.

Any ideas?

John - 7/7/2008 8:37:06 PM
1. You can set the parameters from the code:
SqlDataSourceEvents.SelectParameters["start"].DefaultValue = DateTime.Today.ToString("s");
2. You can also declare the source in the .aspx:
<asp:ControlParameter Name="start" ControlID="DayPilotCalendar1" PropertyName="StartDate" />

Dan Letecky - 7/14/2008 10:04:23 AM

Where would you put this?

Would it go everywhere you call DayPilotScheduler1.DataBind() ?

For example

Private Sub DayPilotScheduler1_Refresh(ByVal sender As Object, ByVal e As DayPilot.Web.Ui.Events.RefreshEventArgs) Handles DayPilotScheduler1.Refresh

'here?
DayPilotScheduler1.DataBind()
DayPilotScheduler1.Update()
End Sub


John - 9/5/2008 5:10:26 PM
Post reply